How to find out where the alert is raised from?

后端 未结 4 1422
悲&欢浪女
悲&欢浪女 2021-01-30 10:06

I\'m just curious to know
Is there ANY ways in ANY browser to find out where the alert I get is raised from?

I tried it in chrome but there is no call stack availabl

4条回答
  •  花落未央
    2021-01-30 11:00

    How about wrapping the alert?

    window.original_alert = alert;
    alert = function (text) {
        // check the stack trace here
        do_some_debugging_or_whatever();
    
        // call the original function
        original_alert(text);
    }
    

    This should be cross-browser.

提交回复
热议问题