object doesnt support this property or method

This question already has an answer here:

  • Why doesn't indexOf work on an array IE8? 7 answers

  • Because IE8 doesn't have an indexOf() method for arrays. You'll have to include a polyfill. Take a look at this post for an example.

    if (!Array.prototype.indexOf)
    {
      Array.prototype.indexOf = function(elt /*, from*/)
      {
        var len = this.length >>> 0;
    
        var from = Number(arguments[1]) || 0;
        from = (from < 0)
             ? Math.ceil(from)
             : Math.floor(from);
        if (from < 0)
          from += len;
    
        for (; from < len; from++)
        {
          if (from in this &&
              this[from] === elt)
            return from;
        }
        return -1;
      };
    }
    
    链接地址: http://www.djcxy.com/p/18958.html

    上一篇: indexOf在IE8中抛出错误,我正在使用knockoutjs

    下一篇: 对象不支持这个属性或方法