代碼如下:
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中顯示又完全正常。
后來(lái)發(fā)現(xiàn),原來(lái)360瀏覽器的極速模式調(diào)用的是Google瀏覽器的Chrome內(nèi)核,所以Chrome瀏覽器里這段代碼也是不起作用。
解決辦法:
代碼如下:
//將:
context.Response.ContentType = "text/plain";
//改為:
context.Response.ContentType = "text/html";
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com