Chrome blocking of additional dialogs? Javascript manipulation?
Chrome gives you the option of blocking additional alert boxes on a website.
How exactly do they do this? Do they directly manipulate your javascript, because somewhere in your code, you will have alert('hello');
So what happens to this code once the user ticks "prevent this site creating additional dialog开发者_Python百科s"?
think of it this way, your js interacts with browser's and then browser uses your OS's APIs to do something which it cannot do by itself. Browser is the middle man and it simply stops any further calls to it's internal alert
function (which ultimately shows the dialogue) from that domain/tab.
Chrome (and all browsers that have this option) will simply don't show anything for the next alerts call if the user don't want them to appear. Your code will run as expected but without popping alerts.
The underlying code seems to be:
if (suppress_this_message) {
// If we are suppressing messages, just reply as if the user immediately
// pressed "Cancel".
OnDialogClosed(reply_msg, false, string16());
}
So it won't display anything; rather it acts as if the user immediatey presses the button, i.e. it acts as if the window is immediately closed .
精彩评论