How to find out where the alert is raised from?

后端 未结 4 1467
悲&欢浪女
悲&欢浪女 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条回答
  •  萌比男神i
    2021-01-30 11:05

    You can overwrite alert, and create an Error for the stack trace:

    var old = alert;
    
    alert = function() {
      console.log(new Error().stack);
      old.apply(window, arguments);
    };
    

提交回复
热议问题