·您当前的位置:主页 > 技术教程 > JavaScript >

[JS]IE浏览器版本如何用js代码检测和识别(ie版本判断)

时间:2017-11-08 16:17酷播
[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; })();

热门文章

请稍候...
  • 热身双十一,锁定云视频大聚惠
  • 备战双十一,相约直播超值狂欢
保利威视云直播
保利威视云视频
微信付费直播
酷播云免费在线视频整体解决方案
酷播v4.0网页播放器