alert('彈出對話框!')") 后跟Response.Redirect("page.aspx");不能彈出對話框,直接跳轉頁面了 如何解?" type="hidden"/>

Response.Write("") 后跟Response.Redirect("page.aspx");不能彈出對話框,直接跳轉頁面了 如何解?


Response.Write和Response.Redirect一起用的時候就會這樣,write腳本和redirect腳本不能同時使用,這樣不會執行腳本,最好使用ClientScript

改進方法:

方法一:

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language=javascript >alert('彈出對話框!');</script>");
Response.Redirect("page.aspx");

 方法二:

Response.Write("<script>alert('彈出對話框!');window.location.href = 'page.aspx';</script>");

方法三:

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script language=javascript >alert('彈出對話框!');window.location.href = 'page.aspx';</script>");

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM