• JS通过内核判断各种浏览器区分360与谷歌


    JS通过内核判断各种浏览器区分360与谷歌

    function getBrowser() {
      var ua = navigator.userAgent.toLocaleLowerCase();
      var Browser = null;
      if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
        Browser = "IE";
        browserVersion =
          ua.match(/msie ([d.]+)/) != null
            ? ua.match(/msie ([d.]+)/)[1]
            : ua.match(/rv:([d.]+)/)[1];
        return "IE";
      } else if (ua.match(/firefox/) != null) {
        Browser = "火狐";
        return "FF";
      } else if (ua.match(/ubrowser/) != null) {
        Browser = "UC";
        return "UC";
      } else if (ua.match(/opera/) != null) {
        Browser = "欧朋";
        return "OP";
      } else if (ua.match(/bidubrowser/) != null) {
        Browser = "百度";
        return "baidu";
      } else if (ua.match(/metasr/) != null) {
        Browser = "搜狗";
        return "SG";
      } else if (
        ua.match(/tencenttraveler/) != null ||
        ua.match(/qqbrowse/) != null
      ) {
        Browser = "QQ";
        return "QQ";
      } else if (ua.match(/maxthon/) != null) {
        Browser = "遨游";
        return "AY";
      } else if (ua.match(/chrome/) != null) {
        var is360 = _mime("type", "application/vnd.chromium.remoting-viewer");
        function _mime(option, value) {
          var mimeTypes = navigator.mimeTypes;
          for (var mt in mimeTypes) {
            if (mimeTypes[mt][option] == value) {
              return true;
            }
          }
          return false;
        }
        if (is360) {
          Browser = "360";
          return "360";
        } else {
          return "Chrome";
        }
      } else if (ua.match(/safari/) != null) {
        Browser = "Safari";
      }
    }
    function btn() {
      let Browser = getBrowser();
      if ("FF" == Browser) {
        console.log("我是火狐");
      } else if ("IE" == Browser) {
        console.log("我是IE");
      } else if ("UC" == Browser) {
        console.log("我是UC");
      } else if ("op" == Browser) {
        console.log("我是欧朋");
      } else if ("baidu" == Browser) {
        console.log("我是百度");
      } else if ("SG" == Browser) {
        console.log("我是搜狗");
      } else if ("QQ" == Browser) {
        console.log("我是QQ");
      } else if ("AY" == Browser) {
        console.log("我是遨游");
      } else if ("360" == Browser) {
        console.log("我是360");
      } else if ("Chrome" == Browser) {
        console.log("我是谷歌");
      }
    }
    
  • 相关阅读:
    Java 反射机制 ( Java Reflection Mechanism )
    Excel&合并单元格内容无效
    UNIX环境高级编程(19-伪终端)
    UNIX环境高级编程(18-终端I/O)
    UNIX环境高级编程(15-进程间通信)
    UNIX环境高级编程(14-高级I/O)
    UNIX环境高级编程(13-守护进程)
    UNIX环境高级编程(12-线程控制)
    UNIX环境高级编程(11-线程)
    C专家编程(4)
  • 原文地址:https://www.cnblogs.com/wgy0528/p/12655872.html
Copyright © 2020-2023  润新知