如何找出发出警报的位置? [英] How to find out where the alert is raised from?
本文介绍了如何找出发出警报的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道
在任何浏览器中,有什么方法可以找到从何处发出警报的信息?
I'm just curious to know
Is there ANY ways in ANY browser to find out where the alert I get is raised from?
我在chrome中尝试过,但是显示警报时没有可用的调用堆栈.
I tried it in chrome but there is no call stack available when alert shows.
有什么主意吗?
推荐答案
您可以覆盖alert
,并为堆栈跟踪创建Error
:
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);
};
这篇关于如何找出发出警报的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文