[英]How to go back to previous window page after opening a pop-up page in ASP.Net?
[英]ASP.NET - Show a pop up when navigate away from the page and On click of OK go to a specific page
我在頁面上有一個用戶控件。 當我嘗試離開頁面時,我想顯示一個確認框(例如,我單擊了導航到其他URL的鏈接)。 在確認框中,我希望能夠單擊“確定”並單擊“取消”來導航到特定頁面,以執行預期的操作。
以下代碼對我不起作用:
window.onunload = function ()
{
if(confirm('You must make elections for the next plan year (Open Enrollment). Click OK to review that event and submit your elections.'))
{
alert('OK');
window.location.assign('http://www.google.com'); return false;
}
}
有想法嗎?
我建議您在修改它之前保留onunload函數,如下所示:
var existingUnload = window.onunload;
window.onunload = function ()
{
if(confirm())
{
// your custome logic
return false;
}
else
{
existingUnload();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.