当用户在重定向如何调用删除功能然后继续重定向之前单击确定按钮
$(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()
{
}
答案 0 :(得分:2)
$(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()
{
}
答案 1 :(得分:1)
我发现了这个,我们可以使用window.unload,如图所示。谢谢
$(document).ready({
window.onbeforeunload = confirmExit ;
window.onunload = function() { return delete(); }
});
function confirmExit()
{
var ele = document.getElementById ("localchanges") ;
if (ele.value == "1")
return "Changes are not saved. Discard changes?" ;
}
function delete()
{
}