javascript 谷歌浏览器不显示一个网站的警报()弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19529036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 15:53:21  来源:igfitidea点击:

Google chrome not displaying alert() popups for one site

javascriptgoogle-chromebrowser

提问by cssyphus

I was working on a javascript loop that alerted each key value as the loop progressed.

我正在研究一个 javascript 循环,随着循环的进行,它会提醒每个键值。

To speed things along, I checked the box "Prevent this page from creating additional dialogs". Usually this only suppresses popups for the one routine, but they haven't come back.

为了加快速度,我选中了“防止此页面创建其他对话框”框。通常这只会抑制一个例程的弹出窗口,但它们没有回来。

In Google Chrome, alert() messages no longer pop up from that site. Other sites do, but not that site.

在 Google Chrome 中,该站点不再弹出 alert() 消息。其他网站有,但不是那个网站。

Has anyone heard of this before?

有没有人听说过这个?

Q: How can I reset the alert() messages for that site?

问:如何重置该站点的 alert() 消息?

回答by chharvey

You don't need to restart the browser. Just close the tab and reopen it again. It does not need to be Incognito.

您无需重新启动浏览器。只需关闭选项卡并重新打开它。它不需要是隐身。

回答by arroni

Not tested but if you have the problem again I think opening the site in an incognito window will reset the dialogs.

未经测试,但如果您再次遇到问题,我认为在隐身窗口中打开该站点将重置对话框。

Edit: I added this answer which worked for the Chrome build as it was. Updates might have rendered this unnecessary (appreciate not to be marked down!)

编辑:我添加了这个适用于 Chrome 构建的答案。更新可能使这变得不必要(感谢不要被标记!)

回答by Adam

Restart the browser, that should reset that option and show you new dialog boxes.

重新启动浏览器,这应该会重置该选项并显示新的对话框。

回答by cssyphus

FROM THE OP:

从操作:

The solution was to restart the browser. Lose all my tabs? No!!!

解决方法是重启浏览器。丢失我所有的标签?不!!!

However, there's a way to restart your browser and not lose all your tabs.

但是,有一种方法可以重新启动浏览器而不会丢失所有选项卡。

Install the Session Manager add-on. There is a version of Session Manager for both Chrome and for Firefox.

安装会话管理器插件。Chrome 和 Firefox 都有一个会话管理器版本。

Session Manager maintains a running list of your open tabs and will automatically ask you if you want to re-open them ("recover your session") after an unexpected reboot or system crash.

会话管理器维护您打开的选项卡的运行列表,并会在意外重启或系统崩溃后自动询问您是否要重新打开它们(“恢复会话”)。

Additionally, Session Manager will let you save your tabs on demand and reload them at a later time, or after a reboot. You can save your "session" (all open tabs) any time you want, and give the session whatever name you want.

此外,会话管理器可让您按需保存选项卡,并在稍后或重新启动后重新加载它们。您可以随时保存“会话”(所有打开的选项卡),并为会话指定任何您想要的名称。

Finally, when reloading a previous session, you can also choose which tabs to re-open and which tabs to ignore.

最后,在重新加载之前的会话时,您还可以选择重新打开哪些选项卡以及忽略哪些选项卡。

Can't live without it, in either Chrome or Firefox.

无论是 Chrome 还是 Firefox,都离不开它。

Chrome extension

Chrome 扩展程序

Firefox extension

火狐扩展

And if you are using IE . . . well, you have other problems.

如果您使用的是 IE 。. . 好吧,你还有其他问题。

回答by DeadlyChambers

If you want to detect if these are being blocked. You will have to do your own thing with the message you will be dispalying but override the native alert/confirm.

如果您想检测这些是否被阻止。您将不得不对要显示的消息做自己的事情,但要覆盖本机警报/确认。

window.nativeAlert = window.alert;
window.alert = function (message) {
var timeBefore = new Date();
var confirmBool = nativeAlert(message);
var timeAfter = new Date();
if ((timeAfter - timeBefore) < 350) {
    MySpecialDialog("You have alerts turned off, turn them back on or die!!!");
  }
}

window.nativeConfirm = window.confirm;
window.confirm = function (message) {
var timeBefore = new Date();
var confirmBool = nativeConfirm(message);
var timeAfter = new Date();
if ((timeAfter - timeBefore) < 350) {
    MySpecialDialog("You have alerts turned off, turn them back on or die!!!");
}
 return confirmBool;
}

Obviously I have set the time to 3.5 milliseconds. But after some testing we were only able to click or close the dialogs in about 5 milliseconds plus

显然我已将时间设置为 3.5 毫秒。但是经过一些测试,我们只能在大约 5 毫秒内点击或关闭对话框

回答by RobertoFRey

Put this line at the end of body, may be DOM is not ready yet when compiler reads this line

把这行放在 body 的最后,可能是编译器读到这行时 DOM 还没有准备好

<script type="text/javascript" src="script.js"></script>"

回答by Winston

Roberto's answer regarding the placement of the script command before the end of body worked for me. I had spent hours trying to figure out why my console command was not working.

罗伯托关于在正文结束之前放置脚本命令的回答对我有用。我花了几个小时试图弄清楚为什么我的控制台命令不起作用。

回答by Perry Ogwuche

All you have to do is restart your browser. Try it on another browser and see if it works, if it does work (i.e, are you able to see your pop up?), then you should just be able to restart your browser to fix it.

您所要做的就是重新启动浏览器。在另一个浏览器上尝试一下,看看它是否有效,如果它有效(即,你能看到你的弹出窗口吗?),那么你应该能够重新启动浏览器来修复它。

This happened to my on google chrome and I fixed it by quitting and re=opening my browser.

这发生在我的谷歌浏览器上,我通过退出并重新打开浏览器来修复它。