pc wap 判断浏览器ua属性

var ua = navigator.userAgent.toLowerCase();
var Android = String(ua.match(/android/i)) == "android";
var iPad = String(ua.match(/ipad/i)) == "ipad";
var iPhone = String(ua.match(/iphone/i)) == "iphone";
var url = window.location.pathname;
var search = window.location.search;
var hash = window.location.hash;
if((Android || iPhone) && url.indexOf('inquiry') == -1 && url.indexOf('challenge-about') == -1) {
window.location = 'www.baidu.com';

};

判断微信里面  ios 和安卓

function isWeiXin(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return true;
} else {
return false;
}
}
function isIos() {
var u = navigator.userAgent.toLowerCase();

if (u.indexOf('iphone') > -1 || u.indexOf('ipod') > -1 ) {
return true;
}
return false;
}
// 判断是否在微信
if(isWeiXin()){
// 判断微信里面 ios系统
if(isIos()) {

}else{

}
}else {
// 判断不在微信
// 判断不在微信 ios系统
if(isIos()){

}else{

}
}

上一篇:Mrt render


下一篇:Java想要学到精通,这几点一定要掌握