Why "Prevent this page from creating additional dialogs" appears in the alert box?

83,277

Solution 1

It's a browser feature to stop websites that show annoying alert boxes over and over again.

As a web developer, you can't disable it.

Solution 2

What does this mean ?

This is a security measure on the browser's end to prevent a page from freezing the browser (or the current page) by showing modal (alert / confirm) messages in an infinite loop. See e.g. here for Firefox.

You can not turn this off. The only way around it is to use custom dialogs like JQuery UI's dialogs.

Solution 3

You can create a custom alert box using java script, below code will override default alert function

window.alert = function(message) { $(document.createElement('div'))
    .attr({
      title: 'Alert',
      'class': 'alert'
    })
    .html(message)
    .dialog({
      buttons: {
        OK: function() {
          $(this).dialog('close');
        }
      },
      close: function() {
        $(this).remove();
      },
      modal: true,
      resizable: false,
      width: 'auto'
    });
};
Share:
83,277

Related videos on Youtube

Misha Moroshko
Author by

Misha Moroshko

I build products that make humans happier. Previously Front End engineer at Facebook. Now, reimagining live experiences at https://muso.live

Updated on December 16, 2020

Comments

  • Misha Moroshko
    Misha Moroshko over 3 years

    In my Rails 3 application I do:

    render :js => "alert(\"Error!\\nEmpty message sent.\");" if ...
    

    Sometimes, below this error message (in the same alert box) I see: "Prevent this page from creating additional dialogs" and a checkbox.

    What does this mean ?

    Is that possible not to display this additional text and checkbox ?

    I use Firefox 4.

    • Ankur
      Ankur about 13 years
      The browser think that you js code has some bug and it is showing the message very frequently in some sort of loop and hence browser provide the option to user to disallow this alert box
    • Shadow The Kid Wizard
      Shadow The Kid Wizard about 13 years
      Chrome show this from the second alert onwards regardless of the content or length of these alerts..
    • Dan Bechard
      Dan Bechard almost 9 years
      @ShadowWizard As of today, it seems to be based on elapsed time since previous alert was closed. The timer is around a second or so.
    • Shadow The Kid Wizard
      Shadow The Kid Wizard almost 9 years
      @Dan yeah, probably they changed it over the years. :)
  • Marcel Korpel
    Marcel Korpel about 13 years
    Just to add: from Firefox 4 onwards those alerts are not modal anymore, at least not to the window manager. You can easily navigate away to other tabs/windows nowadays.
  • GalacticCowboy
    GalacticCowboy over 12 years
    "alert and confirm is the only way to stop the execution of a script at a certain point" - When you're thinking synchronously, that's true. However, these can use the jQueryUI controls to fire another method that then handles the result.
  • mozey
    mozey about 12 years
    It is true when you're thinking asynchronously as well. Using callbacks does not stop code executing in between. But as you say, passing in a callback function is a great way to control flow when using the jQuery dialogs.
  • drooh
    drooh over 8 years
    Can you show how to use this? Maybe add a little description of how to use and whats happening?