0
点赞
收藏
分享

微信扫一扫

识别IE11浏览器


现在俺们做的系统十分高大上,用IE的话非要上IE11或以上版本。

咋检测呢?检测到用户用IE、且IE低于IE11的话就提示他升级浏览器呢?可以酱紫:

var _IE = (function (d, w)
return d.querySelector ? d.documentMode : (d.compatMode == "CSS1Compat" ? "XMLHttpRequest" in w ? 7 : 6 : 5);
}(document, this));

if (typeof _IE == "undefined") {
alert("非IE浏览器");
}
else if (_IE < 11) {
alert("请升级浏览器到IE11");
}
else {
alert("恭喜!");
}

据说html可以识别IE浏览器及其版本。如

<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh-CN">
<!--<![endif]-->

对于这些神秘的注释,非IE浏览器就真的会无视它,当它是注释而已;而IE浏览器,据说可以识别。

我灵机一动,能够酱紫:

<!--[if IE 9]> <script>var ie9 = true;</script> <![endif]-->
<script>if(typeof ie9 != "undefined"){
alert("哇靠,您是IE9!");
}
</script>

事实证明,这不起作用。看来这种注释,只对html有效果。

我好讨厌IE。


举报

相关推荐

0 条评论