[ASP.NET]彈出訊息視窗後導向指定網頁的問題

  • 35282
  • 0
  • 2010-08-02

在ASP.NET中,如何彈出訊息視窗後,按下確定才導向指定網頁

假如想要在導向指定的網頁前,跳出訊息視窗的話,則使用以下方式的話,則訊息視窗會沒有跑出來,且導向指定的頁面

Response.Write("<script>alert('測驗時間到!')</script>")
Response.Redirect("result.aspx")

 

這時可以改用以下方式即可跳出訊息視窗,按下確定後轉向指定的網頁

Response.Write("<script language=javascript>alert('測驗時間到!')</script>")
Response.Write("<script language=javascript>window.location.href='result.aspx'</script>")

 

(2009/4/3 更新)

也可以使用以下語法,此語法來自 Allen 大大 在藍色小舖的回覆

Response.Write("<script>alert('測驗時間到!');location.href='result.aspx';</script>")

 

參考

http://www.studyems.com/network/c82e40938bcfd923.html

http://www.blueshop.com.tw/board/show.asp?subcde=BRD20090329205353MXW&fumcde=