判断移动端UA自动跳转

来源:互联网 发布:linux dirname 编辑:程序博客网 时间:2024/05/22 06:43
判断访问设备,如果是手机访问PC,自动跳转到移动端页面:
  1. <script type="text/javascript">  
  2.         (function(W){  
  3.             if(/iphone|nokia|sony|ericsson|mot|samsung|sgh|lg|philips|  
  4. panasonic|alcatel|lenovo|cldc|midp|wap|  
  5. mobile/i.test(navigator.userAgent.toLowerCase())){  
  6.                 W.location.href = '跳转地址';  
  7.             }  
  8.               
  9.         })(window)  
  10. </script> 

原创粉丝点击