//判断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
isFromWeiXin () {
var
ua = navigator.userAgent.toLowerCase();
if
(ua.match(/MicroMessenger/i) ==
"micromessenger"
) {
return
true
;
}
}
// 检测是否移动端
if(/iphone|ios|android|mini|mobile|mobi|Nokia|Symbian|iPod|iPad|Windowss+Phone|MQQBrowser|wp7|wp8|UCBrowser7|UCWEB|360s+Aphones+Browser|blackberry/i.test(navigator.userAgent)) {
location.href = '移动端地址';
}
// 检测是否移动端
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
window.location.href = "移动端地址"+location.search;
}
//检测是否PC端
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
window.location.href = "PC端地址"+location.search;
}