判断手机类型
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'; }