Posted By

eltweet on 06/15/11


Tagged

alert


Versions (?)

Disable Alerts


 / Published in: JavaScript
 

  1. /*<!-- Fri, 28 Jan 2011 20:42:25 GMT+0000
  2.  
  3. <a href="http://javascript.internet.com/snippets/alert-box-protection.html">The JavaScript Source: Snippets : Alert Box Protection</a>-->*/
  4.  
  5. /*<!-- Add this snippet to the beginning of your code for testing purposes. -->
  6.  
  7.   This script and many more are available free online at
  8. The JavaScript Source :: http://javascript.internet.com
  9.  
  10.   Created by: Benjamin Joffe :: http://www.abrahamjoffe.com.au/
  11.  
  12.   */
  13.  
  14. (function(){
  15.  
  16. var a=window.alert, c=0;
  17.  
  18. window.alert=function(q){
  19.  
  20. /*Change the number below to the number of alert boxes to display before the warning is given.*/
  21.  
  22. if(++c%5==0){
  23.  
  24. if(!confirm(/*q+*/'*** There have been '+c+' alert boxes, continue displaying them?')){
  25.  
  26. window.alert=function(){};
  27.  
  28. confirm('Reload this page?')? location.reload() : '';
  29.  
  30. }}else a(q);};})();
  31.  
  32. for(var i=1;i<50;i++) alert('*** This is an annoying loop of 50 alerts. Every 5th alert you will have an option to exit.\n\n'+i)

Report this snippet  

You need to login to post a comment.