Documentation and Books

Recent site activity

Web Development‎ > ‎JavaScript‎ > ‎

The browser i use doesn't support the Array.indexOf function how to solve this?

To solve this problem add the following piece of JavaScript code to your page, add this between <script> elements and do not put it in a function:

  if (typeof Array.indexOf != 'function') {
Array.prototype.indexOf = function(f, s) {
if (typeof s == 'undefined') {
s = 0;
}

for (var _index = s; _index < this.length; _index++) {
if (f === this[_index]) return _index;
}

return -1;
}
}