gpt4 book ai didi

javascript - 在 IE8 中将 window.onbeforeunload 设置为 undefined 会导致“not implemented 错误

转载 作者:行者123 更新时间:2023-11-30 07:16:06 25 4
gpt4 key购买 nike

            if(!$('fieldset.quote-step4').hasClass('show')) {
window.onbeforeunload = function() {
return "Are you sure you want to leave the quote request page? This will reset the form.";
}
} else {
window.onbeforeunload = undefined;
}

我在私有(private)函数内的脚本中有上面的内容,导致 ie8 中出现“未实现”错误。

具体导致错误的行是:window.onbeforeunload = undefined;

根据我在其他问题中所读到的内容,window 应该声明为局部变量以解决此问题——但我不确定如何声明。

任何人都可以向我解释这个错误和可能的解决方案吗?

谢谢!

最佳答案

试试这个:

$(window).on('beforeunload', function() {
if($('fieldset.quote-step4').hasClass('show')) {
return;
}
return "Are you sure you want to leave the quote request page? This will reset the form.";
});

当 jQuery 已经在您的页面上时,使用 DOM1 处理程序并不是最好的主意。

关于javascript - 在 IE8 中将 window.onbeforeunload 设置为 undefined 会导致“not implemented 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17115730/

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