javascript Alert - disable "Block confirmation windows of this page?"

Asked

Viewed 4,319 times

5

When we use Alert several times it opens a checkbox where the user has the option to disable Alert, there is some way to disable this feature? ( Never show the checkbox )

inserir a descrição da imagem aqui inserir a descrição da imagem aqui

  • Change your browser settings. See http://forums.mozillazine.org/viewtopic.php?f=25&t=2172671&p=10737317#p10737317

  • @Heloisarocha tried to set up the successive_dialog_time_limit but did not resolve

2 answers

4

This behavior is from the browser and not from Javascript itself. It works as if it were a browser security tool, to disable this (if possible) has to be done in the browser settings. In the case of a site already in production, it would hardly be possible to block this kind of message to all users.

If you are using this to debug, use console.log().

3

You can combine Javascript, HTML, and CSS to show much more beautiful and sophisticated alerts (e.g., modal windows) than alert browser default.

The browser has no control over these custom alerts and does not give the user the option to block them.

A library you can use for this is the VEX. You can see it working by running the code example below:

vex.defaultOptions.className = 'vex-theme-os';

function mostreFeedback(mensagem) {
  jQuery("#feedback").attr('value', mensagem);
}

function confirmacao() {
  vex.dialog.confirm({
    message: 'Você tem certeza que deseja fazer isso?',
    callback: function(resultado) {
      if (resultado) {
        mostreFeedback("Ação confirmada com sucesso");
      } else {
        mostreFeedback("Ação cancelada");
      }
    }
  });

}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/vex-js/2.3.3/css/vex-theme-os.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/vex-js/2.3.3/css/vex.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/vex-js/2.3.3/js/vex.combined.min.js"></script>

<input type="button" value="Confirmação" onclick="confirmacao()" />

<br />
<br />

<input id="feedback" type="text" readonly style="width: 100%" />

  • 1

    Ulyssesalves Our library and show!! Helped me a lot here and despite being simple to do many things with it.

  • 1

    I’m glad it was useful, @Williancoqueiro. I also found it a very useful library. Any questions about how to use can ask that we try to clarify. [s]

  • You already attribute it here to many things here. You can tell me if I can get it to Alert and close after a few seconds?

  • 1

    I found a solution, I warn you not to waste your time: setTimeout(function(){vex.close()()}, 3000);. It closes the previous box. Too bad it closes without fading. I will search the library to see if I can change.

  • Today is well run here, I even saw your comment why I’m researching in stackoverflow about a problem that is occurring in an application here. I took a quick look at the Vex API, only thing I saw there was the option closeClassName and the plugin vex-dialog (https://github.com/bbatliner/vex-dialog). When I have more time I look more calmly to try to figure out how to do this too. If.

  • Then Vex.close() closes the previous box. More closes immediately, and does not fade. Vex.closeall() closes all.

  • I got it this way too, which is how it happens when we click OK: setTimeout(function(){$('.vex-dialog-button-primary.vex-dialog-button.vex-first').submit();}, 5000); Already to click Cancel is used: setTimeout(function(){$('.vex-dialog-button-secondary.vex-dialog-button.vex-last').submit();}, 5000);

  • Another thing that I found interesting that to reset the name of the buttons before each window. vex.dialog.buttons.YES.text = 'Sim'&#xA;vex.dialog.buttons.NO.text = 'Não'

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.