zoukankan      html  css  js  c++  java
  • 360极速模式(Chrome内核)下由ashx输出的JavaScript代码不起作用

    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";
  • 相关阅读:
    JS函数防抖与函数节流
    AJAX问题 XMLHttpRequest.status = 0是什么含义
    通过JS如何获取IP地址
    关于URL编码
    报错Unexpected token u
    css文本超出2行就隐藏并且显示省略号
    At_speed_test
    Logic Bist Arch
    Logic BIST
    DMA-330(二)
  • 原文地址:https://www.cnblogs.com/lhl98/p/2988288.html
Copyright © 2011-2022 走看看