RSS

Find out where this JS Alert is invoked

29 Apr

Ever run into a situation where you have an alert popping up from JavaScript and your not sure where it is coming from. Here is a good technique for forcing a stack trace on all alert()‘s by overriding the Alert function.

var old = alert;

alert = function() {
    try {
        throw new Error;
    } catch(e) {
        console.log(e.stack);
    }

    old.apply(window, arguments);
};

Original Article:  http://stackoverflow.com/questions/7808665/how-to-find-out-where-the-alert-is-raised-from

Advertisements
 
Leave a comment

Posted by on April 29, 2012 in html, javascript, personal, web

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: