views:

1312

answers:

2

How can I access events added with attachEvent() / addEventListener() in JavaScript?

Use case: debug events using FireBug's console.

+3  A: 

There is no way to access them.

Depending on what you're trying to achieve, better way to debug the events might be to output the event properties you're interested in from the event handler function...

kkyy
A: 

If you always add and remove handlers with a custom method, you can maintain a log of them in the same method. It adds some overhead to do so.

For example, here is a piece that concerns IE-

//Run=window.Run || {Shadow:{},nextid:0};

else if(window.attachEvent){    
    Run.handler= function(who, what, fun){
     if(who.attachEvent){

      who.attachEvent('on'+what, fun);

      var hoo=who.id || who.tagName+(++Run.nextid);
      if(!Run.Shadow[hoo])Run.Shadow[hoo]={};
      if(!Run.Shadow[hoo][what])Run.Shadow[hoo][what]=[];
      Run.Shadow[hoo][what].push(fun);
     }
    }
}
kennebec