• 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>
    

      

      

  • 相关阅读:
    json批量设置DIV属性
    随机产生div背景颜色变化
    发送验证码倒计时
    购物网站倒计时
    ARC066B
    [Poi2011]Conspiracy
    CF1103E Radix Sum
    NOI2018 冒泡排序
    CometOJ 5E
    NOI2020 命运
  • 原文地址:https://www.cnblogs.com/xuyan1/p/7064669.html
Copyright © 2020-2023  润新知