The js code output by ashx under the Chrome kernel does not work

  • 2020-05-30 19:49:32
  • OfStack


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");
        }
    }

Call in form.ashx:


Script.AlertAndGoBack(" Warm tip: repeat users! ");

As a result, in the new version 6.0 of 360, 1 does not work directly, just output


<script type="text/javascript">
//<![CDATA[
    alert(' Warm tip: repeat users! ');
    window.history.back();
//]]>
</script>

But in IE it's completely normal.

It turned out that the speed mode of the 360 browser called the Chrome kernel of the Google browser, so the code in the Chrome browser did not work.

Solutions:


// Will: 
context.Response.ContentType = "text/plain";
// To: 
context.Response.ContentType = "text/html";


Related articles: