Is it true that IE7 doesnt support indexOf javascript? [duplicate]

安稳与你 提交于 2019-12-06 20:40:14

问题


Possible Duplicate:
.indexOf function on an array not working in IE7/8 using JavaScript

Im developing for IE7 and have some troubles with the javascript function indexOf.

After browsing some sites I read that IE7 doesnt support indexOf. Is this correct, and if so, whats the easiest way to check if a string contains a given string?

var test = window.location.toString();
test = test.toLowerCase();
var idString = "28A3CASDGAGHTSDASF34134";
idString = idString.toLowerCase();
if(test.indexOf(idString) > 0){
  alert('worked');
}

Edit: Most likely some coding error by myself


回答1:


As far as I'm aware, Array.indexOf isn't supported, however String.indexOf, as per your example above, is.

The best way to work things like this out are to just try them in the browser you're querying. This is much more reliable than asking someone else, people have different browser configurations etc.

Update: See this MSDN documentation page about indexOf, it's been supported since IE6.



来源:https://stackoverflow.com/questions/5937609/is-it-true-that-ie7-doesnt-support-indexof-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!