Microsoft IE Javascript support added

There, after spending a while figuring out why
if ( something.indexOf(select_groups[i]) == -1 ) {
threw an error; I was finally able to restore IE support. (poor misguided souls needn’t miss out on the Javascript goodies)

Apparently (Try to wrap your brain around this) the javascript version in IE doesnt support Array.indexOf()! All other browsers do, just not The Internet Explorer! (You can explore, but dont go in too far.) And I’m talking about IE8 here, not IE6..

More on that topic on this blog post “JavaScript Support and Array.indexOf in IE” (2008-08-13 – yes, 2008 and still its an issue!) The post also goes into the history; turning Mind boggling “WTF??” into “oh, MS is just being lazy”..

I did have to tinker slightly before it worked as expected; their solution returns nothing instead of -1 when no element was found. The solution is really simple
if (!Array.indexOf) {
Array.prototype.indexOf = function (obj, start) {
for (var i = (start || 0); i < this.length; i++) {
if (this[i] == obj) {
return i;
return -1;

and actually to be found in the last comment; though I only discovered that AFTER figuring this out myself. Took me a second to realize the code wasn’t returning the -1 I needed for the rest of the code to do its jazz..

Published by Gert


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: