It depends on how the event handlers were attached to the element.
If they are connected using addEventListener or one of the listener's own addWhatever methods, there is no way to list them.
If they are attached by changing the property of the event, i.e. node.onclick = whatever, then you can read the value of the property to get the function, and it will work just like any other JS function.
There is a third way:
You can override the default behavior of addEventHandler / addListener if the code you are using automates. By doing this, you can replace the default behavior with one that pushes each handler into an array, which you can then iterate through yourself.
The following code may work:
var oldAddEventListener = HTMLElement.prototype.addEventListener; HTMLElement.prototype.addEventListener = function(event, handler, bubbling) { oldAddEventListener.call(this, event, handler, bubbling); }
Jani Hartikainen Sep 17 '09 at 6:07 2009-09-17 06:07
source share