Copy codeThe Code is as follows:
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 ");
}
}
In form. ashx, call:
Copy codeThe Code is as follows:
Script. AlertAndGoBack ("Note: There are duplicate users! ");
The result is no longer effective in the new version 360 of 6.0, but the output is
Copy codeThe Code is as follows:
<Script type = "text/javascript">
// <! [CDATA [
Alert ('note: There are duplicate users! ');
Window. history. back ();
//]>
</Script>
But it is completely normal in IE.
Later, it was found that Google's Chrome kernel was called in the speed mode of the 360 browser, so this code does not work in the Chrome browser.
Solution:
Copy codeThe Code is as follows:
// Set:
Context. Response. ContentType = "text/plain ";
// Change:
Context. Response. ContentType = "text/html ";