识别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。

转载于:https://www.cnblogs.com/leftfist/p/6808687.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值