Search code examples
javascriptalert

Is there any chance to find source of javascript alert?


I'm working in a large project that was developed for several years and had tons of code. Recently uninformative alert start to appear. It just says Undefined. I need to find the source of this alert. Is the any chance to make something like "breakpoint on alert"? I want to see the source of this alert. One possibility is to redefine alert function. I tried to make it in firefox without any success.


Solution

  • I'd go with redefining window.alert right at the start of the code for this type of development purposes.

    window.alert = function(e){ console.warn( "Alerted: " + e ); }
    

    This will give You a line number for sure. ( Tested on chrome console )