pc 和 手机端 判断
function IsPC() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}
function Is_weixn(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return true;
} else {
return false;
}
}
function panduan(urls){
if(Is_weixn()){
window.location.href = urls["weixin"];
}else if(IsPC()){
window.location.href = urls["pc"];
}else{
window.location.href = urls["shouji"];
}
}
var urls = new Array();
urls["weixin"] = "http://www.baidu.com";
urls["shouji"] = "http://www.baidu.com";
urls["pc"] = "http://www.baidu.com";
panduan(urls);
其它相关链接
Js判断客户端是否为PC还是手持移动设备