zoukankan      html  css  js  c++  java
  • 判断浏览器内核/适配不同浏览器

    GetBrowserCore.js

    export default () => {
      var sBrowser = null
      var sUsrAg = window.navigator.userAgent
      // The order matters here, and this may report false positives for unlisted browsers.
      if (sUsrAg.indexOf('Firefox') > -1) {
        sBrowser = 'Mozilla Firefox'
        // 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0'
      } else if (sUsrAg.indexOf('Opera') > -1) {
        sBrowser = 'Opera'
        // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106'
      } else if (sUsrAg.indexOf('QQ') > -1) {
        sBrowser = 'QQ'
        // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106'
      } else if (sUsrAg.indexOf('UC') > -1) {
        sBrowser = 'UC'
        // 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106'
      } else if (sUsrAg.indexOf('Trident') > -1) {
        sBrowser = 'Microsoft Internet Explorer'
        // 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko'
      } else if (sUsrAg.indexOf('Edge') > -1) {
        sBrowser = 'Microsoft Edge'
        // 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299'
      } else if (sUsrAg.indexOf('Chrome') > -1) {
        sBrowser = 'Google Chrome or Chromium'
        // 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36'
      } else if (sUsrAg.indexOf('Safari') > -1) {
        sBrowser = 'Apple Safari'
        // 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1 980x1306'
      } else {
        sBrowser = 'unknown'
      }
      return sBrowser
    }

    引用

    import GetBrowserCore from '../../utils/GetBrowserCore.js'
    
    const browserCore = GetBrowserCore()
  • 相关阅读:
    用dockerFile和docker build命令 创建带两个数据卷的新镜像
    Docker 学习 3 镜像更多命令 docker commit 提交容器副本,使之成为一个新的镜像
    Docker学习笔记 2 更多的容器命令
    Docker的学习1 安装 与 基础篇
    SeekBar(拖动条)
    本周总结
    ProgressBar(进度条)
    Android对话框
    css语法
    css基础
  • 原文地址:https://www.cnblogs.com/it-Ren/p/12179501.html
Copyright © 2011-2022 走看看