本文介绍了window.onbeforeunload在弹出窗口中的Firefox 46上不起作用,所有其他浏览器都可以工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Firefox 46出现问题,在所有其他浏览器上都可以正常工作.从页面退出后,我会问以下问题. Firefox完全忽略了它.请帮忙!
Having an issue with Firefox 46, on all the other browsers it work fine.Upon exit from the page I ask the following question. Firefox ignores it completely.Help please!
window.onbeforeunload = ThisCheckExittingPage;
var ThisCheckExitWindow = 1;
// Checks before exitting
// ThisCheckExitWindow = 1;
// Does NOT check before exitting
// ThisCheckExitWindow = 0;
function ThisCheckExittingPage() {
if (ThisCheckExitWindow == 1)
{
return "You are about to exit this page.";
}
}
推荐答案
这看起来像是设计的 WindowEventHandlers.onbeforeunload-Web API | MDN 有此注释:
This looks like by design, as WindowEventHandlers.onbeforeunload - Web APIs | MDN has this note:
如相关补丁所示,设置了mUserHasInteracted
标志变量在窗口中发生鼠标或键盘事件后.
As the relevant patch shows, the mUserHasInteracted
flag variable is set after a mouse or keyboard event happens in the window.
这篇关于window.onbeforeunload在弹出窗口中的Firefox 46上不起作用,所有其他浏览器都可以工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!