asp.net开发 后台用c#, 动态生成了一个htm网页 保存在本地是ansi格式 里面的javascript不能执行,用记事本打开另存为utf8格式 就正常执行了 ,
急求高手帮忙 如何直接保存为可以直接执行的utf8格式htm文件Response.Clear();
Response.BufferOutput = true;
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition", "attachment;filename = ge.htm");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.ContentType = "text/html";
string strExcelHeader = string.Empty;
StringBuilder sb = new StringBuilder();
sb.AppendLine( " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
sb.AppendLine(" <html xmlns=\"http://www.w3.org/1999/xhtml\" >");
sb.AppendLine(" <head runat=\"server\">");
sb.AppendLine(" <title>aaa </title>");
sb.AppendLine(" <script type='text/javascript'>");
sb.AppendLine(" sensor = false;");
sb.AppendLine(" </script>");
sb.AppendLine("");
sb.AppendLine(" </head>");
sb.AppendLine("");
sb.AppendLine(" <body onload='init()' id='body'>");
sb.AppendLine("");
sb.AppendLine(" <div id='map3d_container' style='border: 1px solid silver; height: 500px;width:100%;'>");
sb.AppendLine(" <div id='map3d' style='height: 100%;'></div>");
sb.AppendLine(" </div>");
sb.AppendLine(" </body>");
sb.AppendLine(" </html>"); Response.Write(strExcelHeader); Response.End();
急求高手帮忙 如何直接保存为可以直接执行的utf8格式htm文件Response.Clear();
Response.BufferOutput = true;
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition", "attachment;filename = ge.htm");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
Response.ContentType = "text/html";
string strExcelHeader = string.Empty;
StringBuilder sb = new StringBuilder();
sb.AppendLine( " <!DOCTYPE html PUBLIC \" -//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
sb.AppendLine(" <html xmlns=\"http://www.w3.org/1999/xhtml\" >");
sb.AppendLine(" <head runat=\"server\">");
sb.AppendLine(" <title>aaa </title>");
sb.AppendLine(" <script type='text/javascript'>");
sb.AppendLine(" sensor = false;");
sb.AppendLine(" </script>");
sb.AppendLine("");
sb.AppendLine(" </head>");
sb.AppendLine("");
sb.AppendLine(" <body onload='init()' id='body'>");
sb.AppendLine("");
sb.AppendLine(" <div id='map3d_container' style='border: 1px solid silver; height: 500px;width:100%;'>");
sb.AppendLine(" <div id='map3d' style='height: 100%;'></div>");
sb.AppendLine(" </div>");
sb.AppendLine(" </body>");
sb.AppendLine(" </html>"); Response.Write(strExcelHeader); Response.End();
sb.AppendLine(" <head runat=\"server\">");
sb.AppendLine(" <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />"); sb.AppendLine(" <title>aaa </title>"); 添加上這一句試試看。
有中文就会变UTF-8
没有就变成ANSI