I’m writing a search function using Javascript, which is nearly finished and works fine on chrome, but not in explorer. I’ve used the explorer developer tool and it tells me this is the line it can’t handle:
if (compareElement.indexOf(compareString)!== -1 &&
processFindings.indexOf(processes[i]) === -1)
the error is Object doesn’t support this property or method.
the line used to read:
if(compareElement.indexOf(compareString)!== -1)
and it worked fine, it was only when I added the extra condition that explorer couldn’t deal with it.
Can anyone help me with this?
Not all versions of IE have an .
indexOf()method for arrays. There is a polyfill for it that works well though.See here:
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf
This may cause problems with code that does not iterate arrays properly however.