判断是手机端还是pc端

 1 <script type="text/javascript">
 2   if (window.location.toString().indexOf('pref=padindex') != -1) {
 3 
 4   } else {
 5     if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (
 6         /MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/
 7         .test(navigator.userAgent))) {
 8       if (window.location.href.indexOf("?mobile") < 0) {
 9         try {
10           if (/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
11             window.location.href = "/m/index.php";
12           } else if (/iPad/i.test(navigator.userAgent)) {} else {}
13         } catch (e) {}
14       }
15     }
16   }
17 </script>

猜你喜欢

转载自www.cnblogs.com/web-Knowledge/p/10825405.html
今日推荐