判断是否是手机端访问网站

<script type="text/javascript">
var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
var browser  = navigator.userAgent.toLowerCase();
var isMobile = false; 
 for(var i=0; i<mobileAgent.length; i++){ 
    if(browser.indexOf(mobileAgent[i])!=-1){ 
      isMobile = true; 
      //alert(mobileAgent[i]); 
      location.href = 'http://www.test.com';
      break;} 
 } 
</script>

 

©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页