啥年代了还兼容ie678呢,最近接了个单子,做好了对方才要求兼容ie,纳尼?逗我呢,做完了提需求,要知道我可以用flex和grid进行布局呢,做完了想起ie了,这不故意让重做嘛,一番讨价还价,最终决定暂时用一个版本升级提示来解决。
ie10及以上不支持ie浏览器的判断了,因为ie11已经不支持document.all了,下面是支持ie11的版本的,当然ie6-8也是支持的
判断是否是ie浏览器
1 2 3 4 5 6
| function isIE() { if (!!window.ActiveXObject || "ActiveXObject" in window) return true; else return false; }
|
判断是否是ie浏览器及具体的版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function IEVersion() { var userAgent = navigator.userAgent; var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1; if(isIE) { var reIE = new RegExp("MSIE (\\d+\\.\\d+);"); reIE.test(userAgent); var fIEVersion = parseFloat(RegExp["$1"]); if(fIEVersion == 7) { return 7; } else if(fIEVersion == 8) { return 8; } else if(fIEVersion == 9) { return 9; } else if(fIEVersion == 10) { return 10; } else { return 6; } } else if(isEdge) { return 'edge'; } else if(isIE11) { return 11; }else{ return -1; } }
|