本文介绍了IE:indexOf导致“对象不支持此属性或方法”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下if语句:
if (buyArray.indexOf(dealWith,0) != -1){
在对象不支持此属性或方法。
Which is breaking in ie (ie 8 on XP) with "object doesn't support this property or method".
任何人都可以解决此问题吗?
Anyone have a work around for this?
推荐答案
是的,IE< 9不支持 indexOf
。你可以像这里展示的那样实现一个垫片:
yeah, IE<9 doesn't support indexOf
. You can implement a shim like the one showed here: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
或者如果你已经在使用jQuery,你可以使用。 也有实现。
Or if you already using jQuery you can use inArray. Also underscore has an implementation for it.
这篇关于IE:indexOf导致“对象不支持此属性或方法”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!