[英]How do I disable the "Leave page" confirmation dialog in Firefox?
我的Vue
应用程序中有以下代码,用于检测用户何时关闭选项卡:
onBeforeUnload() {
window.onbeforeunload = null;
return undefined;
}
禁用“离开页面”确认对话框在 Chrome 中有效,但在 Firefox 上无效。 这是为什么? 如何禁用 Firefox 上的确认对话框?
编辑 1:添加和删除beforeunload
侦听器
created() {
window.addEventListener('beforeunload', this.onBeforeUnload);
},
beforeDestroy() {
window.removeEventListener('beforeunload', this.onBeforeUnload);
}
将我的onBeforeUnload
方法更改为此解决了问题:
onBeforeUnload(e) {
window.onbeforeunload = () => {};
delete e.returnValue;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.