JS-判断设备操作系统是Andorid还是IOS

悠悠 2022-04-03 19:28 338阅读 0赞

使用current-device.min.js判断设备操作系统是Andorid还是IOS。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <script src="https://unpkg.com/current-device/umd/current-device.min.js"></script>
  7. </head>
  8. <body>
  9. </body>
  10. <script>
  11. console.log(device.mobile());
  12. console.log(device.ios())
  13. console.log(device.android())
  14. </script>
  15. </html>

此js库体积非常小,只有1.7kb,在判断设备后会在html标签,添加对应信息,详见官方doc。
github地址:

  1. https://github.com/matthewhudson/current-device

发表评论

表情:
评论列表 (有 0 条评论,338人围观)

还没有评论,来说两句吧...

相关阅读