zoukankan      html  css  js  c++  java
  • js 获取 手机操作系统和手机品牌

    需要引入
    <script src="http://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/mobile-detect/1.4.1/mobile-detect.min.js"></script>
    
    <script> class GetPhone{
         // 获取手机操作系统 static osType(){ const device_type = navigator.userAgent;
             // 对数据进行处理 const md = new MobileDetect(device_type); const os = md.os(); return os }; // 获取安卓品牌 static androidPhone(){ const device_type = navigator.userAgent;
              // 获取手机品牌 const result_list = device_type.split(";"); let index = 0 for (var i = 0; i < result_list.length; i++){ if (result_list[i].indexOf("Build/") > -1){ index = i break } } const model = result_list[index].substring(0, result_list[index].indexOf("Build/")); return model }
        // 获取苹果品牌
        static iosPhone(){
    const device_type = navigator.userAgent;
    const md = new MobileDetect(device_type);
    const os = md.os() + md.version("iPhone");
    const model = md.mobile();
    return model
    }
    }
    </script>

    在这里有些情况下不太准,例如:华为在上边的哪个位置是 系列名,所以实际情况要判断下。  

    参考: https://www.cnblogs.com/justphp/p/8439258.html

  • 相关阅读:
    中文分词算法工具hanlp源码解析
    Hanlp分词1.7版本在Spark中分布式使用记录
    Window离线环境下如何安装pyhanlp
    如何编译运行HanLP自然语言处理包
    函数调用面试题
    构造函数复习
    面向对象的好处
    递归实现查找页面所有节点
    面向对象和原型
    chrome浏览器调试工具的使用
  • 原文地址:https://www.cnblogs.com/ShanCe/p/14366220.html
Copyright © 2011-2022 走看看