0
点赞
收藏
分享

微信扫一扫

判断浏览器是否是微信,判断手机是安卓还是ios

kmoon_b426 2022-01-07 阅读 192

1.判断手机是安卓还是ios

const u = navigator.userAgent;

const iOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

if (iOS) {

console.log("ios");

} else {

console.log("andriod");

}

2.判断浏览器是否是微信

let ua = navigator.userAgent.toLowerCase();

let weixin = ua.indexOf("micromessenger") != -1;

if (weixin) {

   console.log("微信");

}else{

    console.log("不是微信");

}

举报

相关推荐

0 条评论