下面这段代码是判断浏览器是手机浏览器,然后自动跳转到mobile.com,请问怎么修改,才能把不是用手机浏览器的人,在上mobile.com的时候,自动跳转到PC.COM,谢谢。
<script type="text/javascript">
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")<0){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
window.location.href="http://www.mobile.com";
}else if(/iPad/i.test(navigator.userAgent)){
}else{
window.location.href="http://www.mobile.com"
}
}catch(e){}
}
}
</script>
(function() {
var userAgentInfo = navigator.userAgent;
//判断是否支持Touch事件
if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
//判断是否为Pad
if ((userAgentInfo.match(/Android/i) && userAgentInfo.match(/PAD/i)) || userAgentInfo.match(/iPad/i) || (userAgentInfo.match(/Window/i) && userAgentInfo.match(/PAD/i))) {
location.assign('http://www.pc.cn/');
} else {
location.assign('http://www.mobile.cn/');
}
} else {
location.assign('http://www.pc.cn/');
}
})();
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
if(window.location.href.indexOf("?mobile")<0){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
//手机
window.location.href="http://www.mobile.com";
}else if(/iPad/i.test(navigator.userAgent)){
//ipad
window.location.href="http://ipad.com"
}else{
//电脑
window.location.href="http://pc.com"
}
}catch(e){}
}
}
如果前面的判断没错,最后一个else里面的
window.location.href="http://www.mobile.com"
改为
window.location.href="http://www.pc.com"