Reputation: 13
I have a little application on web that uses 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?
Upvotes: 1
Views: 637
Reputation: 155
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
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
Upvotes: 2
Reputation: 104
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.
A good idea is to use modals or plugins like Bootbox to show alerts.
Upvotes: 1