尝试使用 onbeforeunload
然后使用 onunload
但 onunload
脚本似乎不起作用。
window.onbeforeunload = confirmExit();
window.onunload = unloading();
function unloading() {
alert("testicles");
confirm("try");
}
function confirmExit(evt) {
return 'test1';
}
最佳答案
看来你在调用卸载函数时错过了“()”。 试试这个:
window.onbeforeunload = confirmExit();
window.onunload = unloading();
关于javascript onbeforeunload 然后 onunload 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27200850/