2 回答

TA貢獻1871條經驗 獲得超13個贊
class Program
{
? ? static void Main(string[] args)
? ? {
? ? ? ? string saveHtml = "<html>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "<head>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? <title>Select Image</title>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? <script type=\"text/javascript\">" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? function displayImage(elem) {" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? ? var image = document.getElementById(\"canvas\");" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? ? image.src = elem.value;? ? ? ? " +
? ? ? ? ? ? ? ? ? ? ? ? ? "? }" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? </script>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "</head>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "<body>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? <form name=\"controls\">" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? ? <img id=\"canvas\" src=\"pictures/fire1.jpg\" />" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? ? <select name=\"imageList\" onchange=\"displayImage(this);\">" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? ? ? <option value=\"pictures/001JRPchargeable.png\">Fire 1</option>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? ? ? <option value=\"pictures/001JRPNonchargeable.png\">Fire 2</option>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "</select>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "? </form>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "</body>" +
? ? ? ? ? ? ? ? ? ? ? ? ? "</html>";
? ? ? ? File.WriteAllText(@"C:\temp\theFile.html", saveHtml);
? ? }
}

TA貢獻1802條經驗 獲得超5個贊
您可以使用此代碼:
string saveHtml = "<html>" +
"<head>" +
" <title>Select Image</title>" +
" <script type=\"text/javascript\">" +
" function displayImage(elem) {" +
" var image = document.getElementById(\"canvas\");" +
" image.src = elem.value; " +
" }" +
" </script>" +
"</head>" +
"<body>" +
" <form name=\"controls\">" +
" <img id=\"canvas\" src=\"pictures/fire1.jpg\" />" +
" <select name=\"imageList\" onchange=\"displayImage(this);\">" +
" <option value=\"pictures/001JRPchargeable.png\">Fire 1</option>" +
" <option value=\"pictures/001JRPNonchargeable.png\">Fire 2</option>" +
"</select>" +
" </form>" +
"</body>" +
"</html>";
string path = @"D:\Test.html";
System.IO.File.WriteAllText(path, saveHtml)
- 2 回答
- 0 關注
- 196 瀏覽
添加回答
舉報