代碼如下:
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中調(diào)用:
代碼如下:
Script.AlertAndGoBack("溫馨提示:有重復(fù)的用戶!");
結(jié)果在360的新版6.0中,一直不起作用,只是輸出了
代碼如下:
<script type="text/javascript">
//<![CDATA[
alert('溫馨提示:有重復(fù)的用戶!');
window.history.back();
//]]>
</script>
但在IE中顯示又完全正常。
后來發(fā)現(xiàn),原來360瀏覽器的極速模式調(diào)用的是Google瀏覽器的Chrome內(nèi)核,所以Chrome瀏覽器里這段代碼也是不起作用。
解決辦法:
代碼如下:
//將:
context.Response.ContentType = "text/plain";
//改為:
context.Response.ContentType = "text/html";
新聞熱點(diǎn)
疑難解答
圖片精選