源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Chrome内核下由ashx输出的js代码不起作用的解决方法

  • 时间:2021-07-26 06:04 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Chrome内核下由ashx输出的js代码不起作用的解决方法
[u]复制代码[/u] 代码如下:
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中调用:
[u]复制代码[/u] 代码如下:
Script.AlertAndGoBack("温馨提示:有重复的用户!");
 结果在360的新版6.0中,一直不起作用,只是输出了
[u]复制代码[/u] 代码如下:
<script type="text/javascript"> //<![CDATA[     alert('温馨提示:有重复的用户!');     window.history.back(); //]]> </script>
但在IE中显示又完全正常。 后来发现,原来360浏览器的极速模式调用的是Google浏览器的Chrome内核,所以Chrome浏览器里这段代码也是不起作用。 解决办法:
[u]复制代码[/u] 代码如下:
//将: context.Response.ContentType = "text/plain"; //改为: context.Response.ContentType = "text/html";
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部