0

The following code works on Chrome, FF and Safari, but not on IE8.

All variables have been tested and are populated.

var videoSubTopics = [60,120,240,300];

function function(e) {
   var index = videoSubTopics.indexOf(Math.floor(e.position));
   if (index >= 0) {
       alert(videoSubTopics[index]);
   }
}

Any ideas?

A Boy Named Su
  • 178
  • 2
  • 8
  • IE8 does not have indexof implamentation check this article http://stackoverflow.com/questions/3629183/why-doesnt-indexof-work-on-an-array-ie8 – Marko Sep 12 '13 at 17:50
  • How does it not work? Check the error console. – Kevin Ji Sep 12 '13 at 17:50

2 Answers2

2

IE8 Arrays does not support the method indexOf

You can refer to this SO Question, and extend the Array Prototype

Why doesn't indexOf work on an array IE8?

In other words: just add the code of that question answer before your call (maybe at the top of your js file)

// the one that starts with: Array.prototype.indexOf = function(elt /*, from*/)
Community
  • 1
  • 1
Roberto Alarcon
  • 1,430
  • 2
  • 18
  • 32
0

IE8 JScript engine doesn't have indexOf