3

I'm working on a website using extensively javascript. The code I'm working on also rely on other big javascript libs. The thing is that somewhere in these libraries, some alert box are poping.

I was wondering if there are some way to disable the javascript alert box on the fly and re-enable it later.

Thanks

ALOToverflow
  • 2,679
  • 5
  • 36
  • 70

1 Answers1

5

Save the old alert function, to a variable.

_alert=alert;

And then set the old alert to either null a custom function.

alert=function(){};
/*or*/
alert = null;

To restore the original version of alert simply reverse step 1.

alert=_alert
GameFreak
  • 2,881
  • 7
  • 34
  • 38