zoukankan      html  css  js  c++  java
  • js获取当前设备信息

    /* 版本信息获取 */
        // 各主流浏览器
        getBrowser() {
          var u = navigator.userAgent
          var bws = [{
            name: 'sgssapp',
            it: /sogousearch/i.test(u)
          }, {
            name: 'wechat',
            it: /MicroMessenger/i.test(u)
          }, {
            name: 'weibo',
            it: !!u.match(/Weibo/i)
          }, {
            name: 'uc',
            it: !!u.match(/UCBrowser/i) || u.indexOf(' UBrowser') > -1
          }, {
            name: 'sogou',
            it: u.indexOf('MetaSr') > -1 || u.indexOf('Sogou') > -1
          }, {
            name: 'xiaomi',
            it: u.indexOf('MiuiBrowser') > -1
          }, {
            name: 'baidu',
            it: u.indexOf('Baidu') > -1 || u.indexOf('BIDUBrowser') > -1
          }, {
            name: '360',
            it: u.indexOf('360EE') > -1 || u.indexOf('360SE') > -1
          }, {
            name: '2345',
            it: u.indexOf('2345Explorer') > -1
          }, {
            name: 'edge',
            it: u.indexOf('Edge') > -1
          }, {
            name: 'ie11',
            it: u.indexOf('Trident') > -1 && u.indexOf('rv:11.0') > -1
          }, {
            name: 'ie',
            it: u.indexOf('compatible') > -1 && u.indexOf('MSIE') > -1
          }, {
            name: 'firefox',
            it: u.indexOf('Firefox') > -1
          }, {
            name: 'safari',
            it: u.indexOf('Safari') > -1 && u.indexOf('Chrome') === -1
          }, {
            name: 'qqbrowser',
            it: u.indexOf('MQQBrowser') > -1 && u.indexOf(' QQ') === -1
          }, {
            name: 'qq',
            it: u.indexOf('QQ') > -1
          }, {
            name: 'chrome',
            it: u.indexOf('Chrome') > -1 || u.indexOf('CriOS') > -1
          }, {
            name: 'opera',
            it: u.indexOf('Opera') > -1 || u.indexOf('OPR') > -1
          }]
          for (var i = 0; i < bws.length; i++) {
            if (bws[i].it) {
              return bws[i].name
            }
          }
    
          return 'other'
        },
        // 系统区分
        getOS() {
          var u = navigator.userAgent
          if (!!u.match(/compatible/i) || u.match(/Windows/i)) {
            return 'windows'
          } else if (!!u.match(/Macintosh/i) || u.match(/MacIntel/i)) {
            return 'macOS'
          } else if (!!u.match(/iphone/i) || u.match(/Ipad/i)) {
            return 'ios'
          } else if (u.match(/android/i)) {
            return 'android'
          } else if (u.match(/Ubuntu/i)) {
            return 'Ubuntu'
          } else {
            return 'other'
          }
        }
  • 相关阅读:
    java 并发性和多线程 -- 读感 (一 线程的基本概念部分)
    [翻译]Spring框架参考文档(V4.3.3)-第二章Spring框架介绍 2.1 2.2 翻译--2.3待继续
    java 内存模型
    控制反转容器& 依赖注入模式 ---读感。
    go json null字段的转换
    分布式数据库----数据同步
    java 多线程--- Thread Runnable Executors
    go runtime.Gosched() 和 time.Sleep() 做协程切换
    sql 里面 join in 的差别,join的用法
    定时器
  • 原文地址:https://www.cnblogs.com/moluxi/p/14299089.html
Copyright © 2011-2022 走看看