Skip to content Skip to sidebar Skip to footer

Script438: Object Doesn't Support Property Or Method 'keys' For Ie

I found strange for the following code: var allextRules = Ext.util.CSS.getRules(); Object.keys(allextRules).forEach(function(key) { var keyname = key; if(keyname.indexOf('

Solution 1:

Try add this code before your

if (!Object.keys) {
  Object.keys = (function () {
    var hasOwnProperty = Object.prototype.hasOwnProperty,
        hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
        dontEnums = [
          'toString',
          'toLocaleString',
          'valueOf',
          'hasOwnProperty',
          'isPrototypeOf',
          'propertyIsEnumerable',
          'constructor'
        ],
        dontEnumsLength = dontEnums.length;

    returnfunction (obj) {
      if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) thrownewTypeError('Object.keys called on non-object');

      var result = [];

      for (var prop in obj) {
        if (hasOwnProperty.call(obj, prop)) result.push(prop);
      }

      if (hasDontEnumBug) {
        for (var i=0; i < dontEnumsLength; i++) {
          if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
        }
      }
      return result;
    }
  })()
};

here is more details about this issue - https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/keys

Solution 2:

in method 'forEach' (error script438: object doesn't support this property or method 'foreEach', in IE 9), the soluction was:

if (!Array.prototype.forEach) {
  Array.prototype.forEach = function(fun/*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")throw new TypeError();
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i inthis)
        fun.call(thisp, this[i], i, this);
    }
  };
}

Font: http://www.tutorialspoint.com/javascript/array_foreach.htm

Post a Comment for "Script438: Object Doesn't Support Property Or Method 'keys' For Ie"