1

I use this code for overriding alert function but after i use this to show my custom alert box it show both of them how can i stop the default alert box ? use preventDefault(); ? where?

(function(event) {

  var proxied = window.alert;
  window.alert = function(str) {
    bootbox.alert(str);
    return proxied.apply(this, arguments);
  };
})();
Sepideh
  • 133
  • 1
  • 1
  • 11

1 Answers1

0

Your code for overriding the default alert function, contains another alert function bootbox.alert(str); due to which it goes into infinite loop showing too much recursion error. You could try below proxy pattern for overriding.

(function(event) {

  var proxied = window.alert;
  window.alert = function(str) {
   //Your code here
   proxied.apply(this, arguments);
   return true;
  };
})();
Vivek Pratap Singh
  • 9,326
  • 5
  • 21
  • 34