View Full Version : failing to retrieve target in FF

12-17-2005, 08:09 AM
hi - this fails in FF when trying to get back the event target. why?

function getindex(a,b){for(var i=0;i<b.length;i++)if(b[i]==a)return i;return false;}

function el(a){
switch(typeof a){
case 'object' : case 'undefined' : return (window.event) ? event.srcElement : a.target;
case 'string' : return document.getElementById(a);
case 'number' : var b = document.getElementsByTagName('*'); return b[Math.max(0,Math.min(b.length-1,getindex(el(),b)+a))];
}}the bit in red is the trouble spot.