There is no Array.indexOf in IE?

Submitted by matthew on March 29, 2010 - 8:54pm

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;
}
}

What is Drupal?

Drupal - a completely free, open source content management system that many organizations are using today to provide for their needs. Drupal's many features and add-ons allow it to be used for a variety of website needs. Drupal is a good choice for today's organizations of any size because it is free, easy, and incredibly flexible.

Copyright © mrconnerton.com, 2008-2010. All Rights Reserved Drupal theme by Kiwi Themes.