zoukankan      html  css  js  c++  java
  • js浏览器对象navigator

    移动端通常需要判断当前设备的类型,比如安卓,ios等。输出浏览器的请求代理,可以判断浏览器类型。js代码如下

    判断当前浏览器的请求代理

    我是出来玩的!
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
    </head>
    <body>
    </body>
    <script>
    // 复制代码扫描可以弹出你的机型
      alert(navigator.userAgent)
      //判断手机系统
      if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
        phoneSystem = "ios";
        alert("我是苹果")
      } else if (/(Android)/i.test(navigator.userAgent)) {
        phoneSystem = "Android";
        alert("我是安卓")
      } else {
        phoneSystem = "other";
      }
    </script>
    </html>
    

      

      

  • 相关阅读:
    docker 安装 redis
    docker 安装 fastdfs
    docker 安装 mysql5.7
    docker 安装 nacos
    docker 安装 gitlab-ce
    gitlab记录
    git记录
    ubuntu命令
    java html table 转 excel,给予jdom 和 poi
    自律挑战
  • 原文地址:https://www.cnblogs.com/xuyan1/p/7064669.html
Copyright © 2011-2022 走看看