2011-10-18 59 views

回答

24

對於那些尋找一個切實可行的解決辦法,請參閱:How to find event listeners on a DOM node when debugging or from the JavaScript code?


EventListenerList對象是DOM 3事件的一些舊的草案,並長期從規範中刪除。據我所知,至少Gecko仍然沒有像常規網頁這樣的東西,儘管它現在有an API for privileged code (extensions) to enumerate listeners(見https://bugzilla.mozilla.org/show_bug.cgi?id=570678#c0)。

我瀏覽了W3C的郵件列表,並且就這個主題進行了一些討論,但是顯然沒有發現用例證明這個功能的合理性。這是我能找到的最新消息:

[...]根本不需要添加此功能的動機是什麼?以前,工作組決定刪除缺少用例的相關但功能較弱的 hasEventListenerNS方法,並且因爲 存在潛在的安全問題。

(2001)http://lists.w3.org/Archives/Public/w3c-wai-ua/2001OctDec/thread.html#msg89在考慮EventListenerList時有一些討論。

(2006)http://lists.w3.org/Archives/Public/www-archive/2006Mar/0032.html向quirksmode的作者問了一個問題,他似乎是負責DOM3 EventListenerList有關這種功能的使用情況的神話;檔案沒有列出答覆。

(2008)另一個討論:http://lists.w3.org/Archives/Public/public-webapi/2008Apr/thread.html#msg66

+0

如果處理程序使用一個JS庫註冊或你想要這個用於調試,看到這個問題的答案:http://stackoverflow.com/questions/446892/how -to-find-event-listeners-on-a-dom-node – Nickolay

+1

如果任何人的狀態是最新的,那麼更新會很棒。現在是2015年:) –

+1

我的用例是克隆一個元素及其事件監聽器。這怎麼不是一個明顯的用例? –

相關問題