Prototype.js claims to be able to stop all woes on handling events in javascript. Well, not really, it seems like.
I have two buttons in a web page adjusting a value up and down. Then I make a shared event handler, and using prototype.js, it starts up like this:
function chchannel(event){
var src=event.element();
if(src.id=='btminus') chno-=1;
else chno+=1; // btplus has been pressed
// and so on.
This works great in firefox, opera and chrome, but fails miserably in internet explorer 8. Somewhere from deep within prototype.js (line 5424 (v. 1.7)) a “‘nodeType’ is null or not an object” error is created. I also tried doing an explisit Event.extend() on the event, but to no avail. Looking into the event object with the debugger, I found the element srcElement which seemed to be what I was looking for and does not exist in firefox (at least, have not checked the others yet), so
var elt;
if(typeof event.srcElement == "object"){
elt=$(event.srcElement.id);
}
else{
elt=event.element();
}