阻止用户关闭标签页或浏览器 window
Prevent user to close tab or browser window
是否可以在 window.onbeforeunload 上开始循环以在选项卡退出时一次又一次地打开同一当前页面?检查以下代码,其工作正常但浏览器将其阻止为弹出窗口打开。
window.onbeforeunload = function(e) {
window.open(document.URL,"_blank");
return 'Dialog text here.';
};
Is that possible to start a loop on window.onbeforeunload to open same
current page again and again on tab exit?
是的。
Why Its not possible?
but browser blocking it as popup opening
您正在测试 javascript
的浏览器的弹出窗口拦截器已打开,以默认阻止此浏览器行为;或者通过您已实施的设置。
解决方案:关闭您正在查看 https://jsfiddle.net/q9kd4b0x/ 的浏览器的弹出窗口阻止程序。
一个新的 window
在一个新的 tab
应该在每个 onbeforeunload
事件中打开
是否可以在 window.onbeforeunload 上开始循环以在选项卡退出时一次又一次地打开同一当前页面?检查以下代码,其工作正常但浏览器将其阻止为弹出窗口打开。
window.onbeforeunload = function(e) {
window.open(document.URL,"_blank");
return 'Dialog text here.';
};
Is that possible to start a loop on window.onbeforeunload to open same current page again and again on tab exit?
是的。
Why Its not possible?
but browser blocking it as popup opening
您正在测试 javascript
的浏览器的弹出窗口拦截器已打开,以默认阻止此浏览器行为;或者通过您已实施的设置。
解决方案:关闭您正在查看 https://jsfiddle.net/q9kd4b0x/ 的浏览器的弹出窗口阻止程序。
一个新的 window
在一个新的 tab
应该在每个 onbeforeunload
事件中打开