JS判断用户手机类型及是否是在微信客户端内部打开网页

时间:2018-11-15 17:08:04   收藏:0   阅读:277

var u = navigator.userAgent;
if (is_weixin() && u.indexOf(‘Android‘) > -1) {//安卓手机

} else if(is_weixin() && u.indexOf(‘Linux‘) > -1){//安卓手机

}else if(is_weixin() && u.indexOf(‘iPhone‘) > -1){//苹果手机

}else if (u.indexOf(‘Windows Phone‘) > -1) {//winphone手机
}
//是否在微信内打开
function is_weixin() {
   var ua = navigator.userAgent.toLowerCase();
   if (ua.match(/MicroMessenger/i) == "micromessenger") {
      return true;
   } else {
      return false;
   }
}

版权声明:本文为博主原创文章,转载请附上博文链接!

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!