Poonam Bhatt
Poonam Bhatt

Reputation: 10302

IE 7 and 8 are having issue with use indexOf with array

I am facing issue with indexOf() of JavaScript with array values. below given code is not working IE 7, 8

e.g.

var wildcards2 = ['test1', 'test2'];
var test = wildcards2.indexOf('test2');
alert(test);

but working fine in Mozila

After this result, there is ajax request in may page. But just because it is not working so , page get submitted instead of sending ajax request.

Upvotes: 0

Views: 43

Answers (1)

Quentin
Quentin

Reputation: 943207

indexOf for Array objects was added in JavaScript 1.6 but IE 7 and 8's JS implementations are closer to JavaScript 1.5 and they do not support indexOf.

The MDN documentation for indexOf includes a compatibility routine that you can copy/paste.

Alternatively, some libraries implement helper functions to provide similar functionality, and you can use them:

Upvotes: 3

Related Questions