发布于 2016-06-07 03:54:18 | 109 次阅读 | 评论: 1 | 来源: 网友投递
ASP.NET
ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。
public class Script
{
public static void Alert(string message)
{
ResponseScript(" alert('" + message + "');");
}
public static void ResponseScript(string script)
{
HttpContext.Current.Response.Write("<script type=\"text/javascript\">\n//<![CDATA[\n");
HttpContext.Current.Response.Write( script );
HttpContext.Current.Response.Write("\n//]]>\n</script>\n");
}
}
在form.ashx中调用:
Script.AlertAndGoBack("温馨提示:有重复的用户!");
结果在360的新版6.0中,一直不起作用,只是输出了
<script type="text/javascript">
//<![CDATA[
alert('温馨提示:有重复的用户!');
window.history.back();
//]]>
</script>
但在IE中显示又完全正常。
后来发现,原来360浏览器的极速模式调用的是Google浏览器的Chrome内核,所以Chrome浏览器里这段代码也是不起作用。
解决办法:
//将:
context.Response.ContentType = "text/plain";
//改为:
context.Response.ContentType = "text/html";