pc跳移动端
//方案一
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))){
try{
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
//触屏手机版地址
var url = window.location.href.replace("http://www","http://m");
window.location.href = url;
}else if(/iPad/i.test(navigator.userAgent)){
//pad版地址
var url = window.location.href.replace("http://www","http://m");
window.location.href = url;
}else{
//普通手机版地址
var url = window.location.href.replace("http://www","http://m");
window.location.href = url;
}
}
catch(e){
}
}
//方案二
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
window.location.href = "移动端地址";
}
//移动端跳pc
var isOnPc=!(/Android|webOS|iPhone|iPod|BlackBerry|BB10|Symbian|Nokia|UCWEB|IEMobile|opera mini/i.test(navigator.userAgent));
//上面这个表示不是移动端
//下面这句话的意思是不是移动端的时候跳转到相应的地址
isOnPc && (location.href="地址");