2011-05-10

how to get a element's eventlistener


发展真快啊 几个月前找这个问题还没有答案 现在chrome和firebug都给了答案

http://stackoverflow.com/questions/4672301/getting-an-elements-eventlisteners
In safari's (and chrome's) element inspector there's an "Event Listeners" section (in the right frame of the elements tab) that show's the Event Listeners in the document. Is there anything similar in firebug? Also, is it possible to get an element's event listeners using javascript (like elmnt.onclick, but should work for events added with addEventListener() as well)?    

This is available for firebug:

http://getfirebug.com/wiki/index.php/Firebug_Extensions#Eventbug

For your second question, is it possible to get the events added via addEventListener in javascript? Generally it is not. That add-on uses eventlistenerservice you would need elevated privileges, a signed script and it would still only work in Firefox.

Eventbug

Eventbug

Eventbug is a Firebug extension that lists all of the event handlers on the page grouped by event type...

没有评论:

所见所闻所思