如何使用JavaScript在DOM节点上查找事件侦听器 [英] How to find event listeners on a DOM node using JavaScript
问题描述
我仍然无法相信这是不可能的,但是有一种方法可以循环浏览dom并查看所有使用'addEventListener'附加的事件处理程序.这篇文章和许多其他人说不.
I still can't belive this is not possible but is there a way to loop through the dom and see all event handlers attached using 'addEventListener'. This post and many others says no.
如果是这种情况,那么Chrome的检查器或Firebug之类的应用如何显示它们呢?我猜他们可能会以某种方式增强dom的方法,以便他们可以跟踪绑定的内容.
If that's the case then how do apps like Chrome's inspector or Firebug show them, which they do? I guess they probably augment the dom's methods in some way so they can track what's being bound.
推荐答案
当然,浏览器在内部具有事件侦听器列表,但不会暴露给页面级JavaScript.例如,Firebug(或 Eventbug )可能使用
Of course browsers internally have a list of event listeners, but it is not exposed to page-level JavaScript. For example, Firebug (or Eventbug) probably use nsIEventListenerInfo.
话虽如此,这个老答案仍然成立:
如何在DOM节点上找到事件监听器?
That being said, this old answer still holds:
How to find event listeners on a DOM node?
这篇关于如何使用JavaScript在DOM节点上查找事件侦听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!