简体   繁体   English

如何检测何时“防止此页面创建其他对话框”被单击

[英]How to detect when “prevent this page from creating additional dialogs” is clicked

I have a little application on web that uses JS Alerts. 我在Web上有一个使用JS Alerts的小应用程序。 I am planning to use modal pops later, but for the time being, does anyone know how to detect if the user clicked on the "prevent this page from creating additional dialogs" and then fire some js function? 我打算稍后使用模态弹出窗口,但暂时,是否有人知道如何检测用户是否单击“阻止此页面创建其他对话框”然后触发一些js函数?

it is indeed possible to detect if prevent additional dialogs has been clicked by working with javascript date you can try this lines of code 确实有可能通过使用javascript日期检测是否阻止了其他对话框,您可以尝试这行代码

 window.nativeAlert = window.alert; window.alert = function(message) { var timeBeforeAlert = new Date(); var confirmIfBlocked = nativeAlert(message); var timeAfterAlert = new Date(); if ((timeAfterAlert - timeBeforeAlert) < 400) { tellTheUserDialog("you can use a Div to tell the user he has blocked alert"); } } 

if users does not see alert then timeAfterAlert will be almost the same as timeBeforeAlert, i used 400 milliseconds just for reference you can come up with yours 如果用户没有看到警报,那么timeAfterAlert将与timeBeforeAlert几乎相同,我使用400毫秒仅供参考,你可以拿出你的

You can't detect it because it is a browser feature which helps the user get rid of indefinite popups. 您无法检测到它,因为它是一个浏览器功能,可以帮助用户摆脱无限期的弹出窗口。 This is particularly useful when your JavaScript code shows popups in a loop. 当您的JavaScript代码在循环中显示弹出窗口时,这尤其有用。

A good idea is to use modals or plugins like Bootbox to show alerts. 一个好主意是使用模块或插件,如Bootbox来显示警报。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM