DevlshOne
DevlshOne

Reputation: 8457

Is there an "all alerts off" script that will disable all alerts?

Suppose I use a lot of alerts during troubleshooting and rather than go back through and remove them all, I would just rather turn them all off? Can it be done? Maybe by re-writing the `alert.prototype?

Upvotes: 0

Views: 104

Answers (1)

Khanh TO
Khanh TO

Reputation: 48972

I guess you need something like:

var oldAlert = window.alert;

window.alert = function(){
   if (enableAlertFunction){
      oldAlert.apply(window,arguments);
   }
}

enableAlertFunction is to toggle on/off all your alert. Remember to run this code first before all the code on your page.

Upvotes: 1

Related Questions