Full version: jsB@nk » Misc » Alert Box Protection
URL: https://www.javascriptbank.com/alert-box-protection.html
Often when working on scripts alert boxes are placed inside loops as a debugging tool. You can sometimes end up with hundreds of alert boxes and no way to stop them. This JavaScript placed at the start of your code will give you an option to disable the alert boxes after a pre-determined number set by you.
Full version: jsB@nk » Misc » Alert Box Protection
URL: https://www.javascriptbank.com/alert-box-protection.html
<script type=text/javascript>//Created by: Benjamin Joffe :: http://www.abrahamjoffe.com.au/ */(function(){ var a=window.alert, c=0; window.alert=function(q){ // Change the number below to the number of alert boxes to display before the warning is given. if (++c%5==0) { if (!confirm(q+'\nThere have been '+c+' alert boxes, continue displaying them?')) window.alert=function(){}; } else a(q); }})();// This is only a test case. You can removed it.function testing() {for (var i=1; i<50; i++) { alert('This is an annoying loop of 50 alerts.\nEvery 5th alert you will have an option to exit.\n\n'+i);}}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<input type="submit" value="Press to test" onclick="testing();"><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->