[JS]IE浏览器版本如何用js代码检测和识别(ie版本判断)
[JS]IE浏览器版本如何用js代码检测和识别
IE11或者非IE
if (!document.all) { alert('IE11+ or not IE'); }
IE10
if (document.all && document.addEventListener && window.atob) { alert('IE10'); }
IE9
if (document.all && document.addEventListener && !window.atob) { alert('IE9'); }
IE8上面已经给出
if (document.all && document.querySelector && !document.addEventListener) { alert('IE8'); }
IE7
if (document.all && window.XMLHttpRequest && !document.querySelector) { alert('IE7'); }
IE6
if (document.all && document.compatMode && !window.XMLHttpRequest) { alert('IE6'); }
检测IE版本
var win = window; var doc = win.document; var input = doc.createElement ("input"); var ie = (function (){ //"!win.ActiveXObject" is evaluated to true in IE11 if (win.ActiveXObject === undefined) return null; if (!win.XMLHttpRequest) return 6; if (!doc.querySelector) return 7; if (!doc.addEventListener) return 8; if (!win.atob) return 9; //"!doc.body.dataset" is faster but the body is null when the DOM is not //ready. Anyway, an input tag needs to be created to check if IE is being //emulated if (!input.dataset) return 10; return 11; })();
热门文章推荐
- [JS]window.location获取url各项参数详解
- [JS]jQuery,javascript获得网页的高度和宽度
- [JS]视频弹窗视频弹出层videoLightBox(含三种播放器的用法)
- [JS]JS提交中文encodeURI两次转码
- [JS]js版方面encodeURI转码和decodeURI解码的用法实例
- [JS]js取当前机子的时间戳实例
- [JS]AES加密(基于crypto-js)PHP后端解密
- [JS]data:image/png;base64写法的用途及说明
请稍候...