gpt4 book ai didi

javascript - window.onbeforeunload 功能

转载 作者:行者123 更新时间:2023-11-30 23:43:42 25 4
gpt4 key购买 nike

当用户在重定向之前点击确定按钮时如何调用删除函数然后继续重定向

 $(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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com