• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a listener

 
Al Gettier
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a given DOM node, is there a way to tell if someone has "addEventListener()" a handler to it?

Can I find out when event is being listened for or what function is being called?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can reference the node/element and look at the code.

alert(document.getElementById("test").onclick);

Eric
 
Al Gettier
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This does not work for me. Here is my code:

document.addEventListener("click", function(e){alert("In My Handler"+e);}, false);
alert("onclick: "+document.onclick);
alert("click: "+document.click);

For both of the alerts I get undefined. This was done in Firefox 1.5
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I ask you why you are doing this?

Also you can delete posts by clicking on the edit icon and checking the delete box. So I do not have to do it next time!

Eric
 
Al Gettier
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for deleting my errant post.

We are trying to provide a quality control product for people who write AJAX appliations.

So what we would like to do is report back all handlers that have (or may have) been called for an event when it happens.

For example we want to attach a listener for "click" at the <body> level. Then when the click occurs we go up the DOM tree, reporting what levels of the DOM have a "click" listener.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic