js判断浏览器所在的客户端类型

判断手机类型
function isphone(){
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {
//安卓手机

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

} else if (u.indexOf('Windows Phone') > -1) {
//winphone手机
       
}else if (u.indexOf('MSIE') > -1) {
//ie浏览器
       
}
}


判断是否为微信

function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger"){
return true;
} else {
return false;
}
}
if(is_weixin()){
     document.getElementById('dd').style.display='block';
}


猜你喜欢

转载自blog.csdn.net/weixin_41187842/article/details/80534485