Tue, 03/30/2010 - 00:54
There is no Array.indexOf in IE?
Who knew!! Apparently mozilla and this guy.
After finishing hours of development on a mapping application at work and finally working all the bugs out, I open it up in IE only to have it crumb to it's knees at the first sign of indexOf. Well thankfully there are people smarter than me out there who had a nifty prototype I just had to throw in to make the application come back to life:
if(!Array.indexOf){
Array.prototype.indexOf = function(obj){
for(var i=0; i<this.length; i++){
if(this[i]==obj){
return i;
}
}
return -1;
}
}



Post new comment