我编写了以下代码来在卸载中运行 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?";
}