判断用户是否是移动设备(手机浏览器、平板电脑)浏览器的方法:
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://m.guzheng.cn/"; }else if(/iPad/i.test(navigator.userAgent)){ window.location.href="http://www.guzheng.cn/"; }else{ //window.location.href="http://m.guzheng.cn/"; } }catch(e) { } } } else { //window.location.href="http://www.guzheng.cn/"; }