JavaScript: Internet Explorer不支持forEach方法
JavaScript: Method forEach not supported from Internet Explorer
我正在使用gzip算法的javascript实现,该算法与Firefox和Chrome一起工作很好。但是在ie浏览器中,我得到了以下错误:
不支持forEach方法!
代码:
deflate.deflate(data, level).forEach(function (byte) {
putByte(byte, out);
});
我使用的是Internet Explorer 9,它应该支持forEach方法。
任何想法?
非常感谢!
对于不支持foreach
方法的浏览器,您可以尝试扩展Array
对象,如Array.forEach
例如:
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(fn, scope) {
for(var i = 0, len = this.length; i < len; ++i) {
fn.call(scope, this[i], i, this);
}
}
}
IE9不支持forEach,您可以尝试使用jquery。
例:
$. each (function (byte) {
putByte(byte, out);
});
相关文章:
- 在JavaScript中中断forEach方法的首选方法
- 将id/类放在HTML中的正确方法是使用foreach来获得确切的值
- 不能调用未定义节点.js的方法“forEach”
- 每次迭代在 Foreach 循环中重复 PHP 睡眠方法
- 如何删除“对象在节点中没有方法'forEach'错误.js”
- 使用 forEach 方法修改 dom 元素
- JavaScript 方法 array.forEach 在 Chrome 中工作吗?
- MongoDB aggregate() - 错误“TypeError: 无法调用未定义的方法'forEach
- 不理解此forEach()方法的输出
- 使用敲除foreach绑定绑定方法名称
- 回调函数的定义以及它如何适用于array.prototype.forEach/map/filter方法
- Jquery.ech()和Array.prototype.forEach()方法的区别
- 如何在knockout.js中的foreach中使用computed方法
- 使用Array.prototype.forEach()方法
- 在Foreach循环中调用Async方法
- JavaScript: Internet Explorer不支持forEach方法
- AngularJS: forEach http get data -等待其他方法,直到所有来自循环的数据被加载
- 为什么字符串变量可以通过JS中的调用使用forEach方法
- 使用forEach方法在javascript
- 为什么ECMAScript 5中Object上没有forEach方法