我已經寫了下面的代碼在卸載中運行onbeforeunload。但是,這似乎並不奏效。有沒有人知道我的代碼有什麼問題,無論如何,使它的工作?onbeforeunload不能在卸載內工作
$(window).unload(function() {
if ($('.submitAction').val() == "" && isChange) {
window.onbeforeunload = confirmExit;
}
});
function confirmExit() {
return "If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
的'beforeunload'事件實際上讓你返回一個字符串,這是用來很好地提示用戶(或惹惱他們購買偉哥).. –
@MikeChristensen - 我會的。好吧,我今天學到了一些新東西。 –