• 检测是否是IE浏览器


    浏览器识别版本方法

    //使用说明返回的是一个对象{"browser":"[IE]...","version":"11.0"}

             function identifyBrowser() {
                var userAgent = navigator.userAgent,
                   rMsie = /(msies|trident.*rv:)([w.]+)/,
                   rFirefox = /(firefox)/([w.]+)/,
                   rOpera = /(opera).+version/([w.]+)/,
                   rChrome = /(chrome)/([w.]+)/,
                   rSafari = ersion/([w.]+).*(safari)/;
                var browser;
                var version;
                var ua = userAgent.toLowerCase();
                function uaMatch(ua) {
                    var match = rMsie.exec(ua);
                    if (match != null) {
                        return { browser: "IE", version: match[2] || "0" };
                    }
                    var match = rFirefox.exec(ua);
                    if (match != null) {
                        return { browser: match[1] || "", version: match[2] || "0" };
                    }
                    var match = rOpera.exec(ua);
                    if (match != null) {
                        return { browser: match[1] || "", version: match[2] || "0" };
                    }
                    var match = rChrome.exec(ua);
                    if (match != null) {
                        return { browser: match[1] || "", version: match[2] || "0" };
                    }
                    var match = rSafari.exec(ua);
                    if (match != null) {
                        return { browser: match[2] || "", version: match[1] || "0" };
                    }
                    if (match != null) {
                        return { browser: "", version: "0" };
                    }
                }
                var browserMatch = uaMatch(userAgent.toLowerCase());
                if (browserMatch.browser) {
                    browser = browserMatch.browser;
                    version = browserMatch.version;
                }
                return {
                    "browser": browser ,
                    "version": version
                };
            }


            function joinConf() {
                var temp = identifyBrowser();
                alert(temp.browser == "IE");
                if (temp.browser== "IE") {
                    if (!initActivxObj()) {
                    }
              
                } else {
                        alert( "请选用IE浏览器!" );
                }
            }

  • 相关阅读:
    Nmap参数详解(含扫描参数原理解释)
    为什么服务器突然回复RST——小心网络中的安全设备
    Security+学习笔记
    《HTTPS权威指南》读书笔记——PKI
    [Android 搞机]Twrp 中清除 data 和搞机清除的区别
    [C语言学习笔记五]复合语句和操作符的区分
    [C语言学习笔记四]变量与系统的交互
    [C语言学习笔记三]格式化输出和输入
    [C语言学习笔记二] extern 函数的用法
    [C语言学习笔记一]基本构架和变量
  • 原文地址:https://www.cnblogs.com/zhtbk/p/4530768.html
Copyright © 2020-2023  润新知