javascript alert - disable "Block confirmation windows from this page?"

5

When we use the alert several times open a checkbox where the user has the option to disable the alert, is there any way to disable this feature? ( Never checkbox )

    
asked by anonymous 31.07.2015 / 22:02

2 answers

4

This behavior is by the browser rather than the JavaScript itself. It works as if it were a browser security tool, so disabling it (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 type of message for all users.

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

    
31.07.2015 / 22:05
3

You can combine JavaScript, HTML, and CSS to display much more beautiful and sophisticated alerts (for example, modal windows) than the browser's default%.

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

One library you can use for this is VEX . You can see it running 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><linkhref="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><inputtype="button" value="Confirmação" onclick="confirmacao()" />

<br />
<br />

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