当用户在重定向之前点击确定按钮时如何调用删除函数然后继续重定向
$(document).ready({
window.onbeforeunload = confirmExit ;
});
function confirmExit()
{
var ele = document.getElementById ("localchanges") ;
if (ele.value == "1")
return "Changes are not saved. Discard changes?" ;
}
function delete()
{
}
最佳答案
$(document).ready({
window.onbeforeunload = confirmExit ;
});
function confirmExit()
{
delete()// call delete function here , once this is done , below codes will be executed
var ele = document.getElementById ("localchanges") ;
if (ele.value == "1")
return "Changes are not saved. Discard changes?" ;
}
function delete()
{
}
关于javascript - window.onbeforeunload 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3793815/