Tuesday, February 7, 2012

event.srcElement vs event.Target

Web development is fun until you stumble over some browser specific issues. One bug we got last week was a script that worked in IE but not in Firefox:
that.selected=function(e){
 var source=e.srcElement;
 //Some extra code...
}


This one is actually a bug in IE, we are using srcElement which is an Internet Explorer proprietary element. The official property is named target, so this fixed the code:
that.selected=function(e){
 var source=e.target;
 //Some extra code...
}

No comments: