首页 > 代码库 > pc wap 判断浏览器ua属性
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{
}
}
pc wap 判断浏览器ua属性