
1、indexOf
//不兼容
if(codeArr.indexOf(code) == -1){
//TODO
}
//修改后
if($.inArray(code,codeArr) == -1){
//TODO
}
2、forEach
IE8浏览器不兼容forEach,把所有forEach改成for
3、map
ie8浏览器不兼容map,需要引入以下代码
if (!Array.prototype.map) {
Array.prototype.map = function(callback, thisArg) {
var T, A, k;
if (this == null) {
throw new TypeError(" this is null or not defined");
}
var O = Object(this);
var len = O.length >>> 0;
if (typeof callback !== "function") {
throw new TypeError(callback + " is not a function");
if (thisArg) {
T = thisArg;
}
A = new Array(len);
k = 0;
while(k < len) {
var kValue, mappedValue;
if (k in O) {
kValue = O[ k ];
mappedValue = callback.call(T, kValue, k, O);
A[ k ] = mappedValue;
}
k++;
}
return A;
};
}
}
悟空浏览器的秘密:如何轻松下载小说和视频?网页版入口大公开!
标签: forEach, indexOf, map, 兼容IE8, 浏览器
上面是“IE8浏览器不兼容indexOf、forEach、map解决方法”的全面内容,想了解更多关于 前端知识 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2158.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

一键生成专业写真和创意头像的AI照片编辑工具——Kacha AI
ThinkPHP如何实现获取SQL的方法
AQ
VisoMaster:一款功能强大且易于使用的AI换脸和编辑软件