Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the alternate function for indexOf for string in IE8?

I have used indexOf to check whether i have particular text is present in a sentence or not like the following

var temp = "";
temp="data not available";
if(temp.indexOf("datas") == 0){
    alert("True");
}
else{
    alert("false");
}

The problem i was facing is indexOf is not supported in Internet Explorer 8. How to perform this operation in IE8 too? Is there any default alternate functions available in jquery?

I tried inArray but it supports only array.

fiddle

like image 567
Pandiyan Cool Avatar asked Feb 14 '14 06:02

Pandiyan Cool


1 Answers

I think you're confused about which indexOf() is supported.

You're using String.prototype.indexOf(), which is supported from IE6 onwards, according to Microsoft's documentation.

It's Array.prototype.indexOf() that's only supported from IE9 onwards.

like image 143
Ja͢ck Avatar answered Nov 14 '22 22:11

Ja͢ck