Forum Moderators: open
1) Get a nodeList of all elements: document.getElementsByTagName("*");
2) Iterate over this list. With each element:
- Enumerate its properties, of which there will be many by default
var regOn = /^on/;
for(var p in elm){
if(regOn.test(p) && elm[p]){
do something with elm[p];
}
}
It's assumed that all event handlers begin with "on". All of these will appear, whether defined or not, so we test to see if they have been.
Problems (that I can think of right now)
1) Unfortunately, I'm pretty sure that event handlers assigned using addEventListener/attachEvent don't enumerate.
2) Need to enumerate the global object (window) separately
Thanks for the quick reply. I got that far i the mean time.
My problem is that via onload I attach events to certain form elements. These events override events & functions
attached to elements like this:
<select name="foo" id="foo" onchange=doStuff(this.value)">
But on some pages I need both. Any ideas?
TIA, AA