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。

  • 相关阅读:
    474. Ones and Zeroes
    [LeetCode]464. Can I Win
    413. Arithmetic Slices
    numpy学习(布尔型索引)
    numpy学习(数组和标量之间的运算切片)
    numpy学习(数组的定义及基础属性)
    关于静态显示游标的遍历
    关于oracle的数组
    shutil模块
    开源库(不定义更新)
  • 原文地址:https://www.cnblogs.com/leftfist/p/6808687.html
Copyright © 2011-2022 走看看