问题描述
如何在切换标签时不允许取消Alert Box。
使用 alert(测试) );
在谷歌浏览器上,当您切换标签时,警报对话框消失,当您返回同一标签时,您可以完全访问。
Using alert("Test");
on Google Chrome, when you switch tabs, the alert dialog box disappears, and when you're back on the same tab you have full access.
当你创建一个问题并尝试关闭标签时,我想要的是做与 stackoverflow 网站相同的事情,弹出一个不允许你去的对话框任何地方,直到你选择(离开或保持)。
What I want is to do the same thing as stackoverflow website when you create a question and try to close the tab, there's a dialog box that pops up that doesn't allow you to go anywhere until you choose between (Leave or Stay).
IE和Firefox的工作方式不同,我的意思是阻止使用提醒(测试);
语句时的标签,但谷歌浏览器不会阻止。
IE and Firefox work differently, I mean block the tab when using alert("Test");
statement but Google Chrome doesn't block.
我发了一个错误报告给谷歌,但他们回复我:
这是按预期工作,请参阅。
这不是安全漏洞;用户可以使用开发人员工具或无数其他技巧使对话框消失。
I sent a bug report to Google but they replied to me that :This is working as intended, see Issue 629964.It's not a security bug; a user could make the dialog box disappear with developer tools or myriad other tricks as well.
推荐答案
我能够通过在iframe
I was able to get around this issue by calling my javascript alert in an iframe
这篇关于Javascript:Alert Box在切换标签时被解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!