我有这样的情况:
if (image.indexOf("/bob/") != -1 || image.indexOf("/grabs/") != -1 || image.indexOf("/") == image.lastIndexOf("/")) {
alert('success');
}
在 IE8 中我得到对象不支持属性或方法“indexOf”
我可能会使用类似 $.inArray("/bob/", image)
的东西,但我不确定 lastIndexOf
有什么想法可以解决这个问题吗?
最佳答案
尝试使用正则表达式,例如
if(/\/(bob|ginger|grabs)\//.test(image) || /^[^\/]*\/$/.test(image)){
}
关于javascript - 如何修复对象不支持属性或方法 'indexOf'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19532064/