JS 判断电脑是 Win 还是 mac?

//判断系统类型
function OSnow() {
  const agent = navigator.userAgent.toLowerCase()
  const isMac = /macintosh|mac os x/i.test(navigator.userAgent)
  if (agent.indexOf('win32') >= 0 || agent.indexOf('wow32') >= 0) {
    //your code
    alert('这是windows32位系统')
  }
  if (agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) {
    //your code
    alert('这是windows64位系统')
  }
  if (isMac) {
    //your code
    alert('这是mac系统')
  }
}
OSnow()
```

传送门:https://juejin.cn/post/6854573221614714893
posted @   DL·Coder  阅读(633)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示