IE8数组不支持indexOf方法
0
最近用户老说下载不了,搞了半天原来是IE8不支持数组的indexOf
方法,万恶的IE啊。
解决办法:
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(value /*, 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] === value) {
return from;
}
}
return -1;
};
}
诶,天天搞浏览器兼容画页面,弄的我都快成前端了。