zoukankan      html  css  js  c++  java
  • 识别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。

  • 相关阅读:
    生产环境经常用到的命令
    JDK 安装部署
    oracle备份脚本
    HTTP与HTTPS的区别
    TCP和UDP的优缺点及区别
    Web服务器优化
    DDOS攻击的三种常见方式
    Xss Csrf DDOS sql注入及防范
    session共享
    Cookie防伪造防修改
  • 原文地址:https://www.cnblogs.com/leftfist/p/6808687.html
Copyright © 2011-2022 走看看