zoukankan      html  css  js  c++  java
  • 检测是否是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浏览器!" );
                }
            }

  • 相关阅读:
    02
    springmvc根据请求uri获取handlermapping源码
    springmvc零xml配置原理
    maven使用tomcat插件出现Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: A child container failed during startd错误
    zipkin以JAR文件启动以Mysql作为持久化方式
    OAuth2AuthenticationProcessingFilter资源认证服务器过滤器
    OAuth2中四种授权模式以及相应操作
    JVM双亲委派机制
    springcloud对应springboot版本【如果版本依赖不对,则会出现一堆神奇的问题】
    python实现一元二次表达式求值
  • 原文地址:https://www.cnblogs.com/zhtbk/p/4530768.html
Copyright © 2011-2022 走看看