码迷,mamicode.com
首页 > 移动开发 > 详细

js判断移动终端url跳转

时间:2015-12-24 23:52:13      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:

CODE

<script>
      //判断终端url跳转 
      function sp_isMobile() {
        return Boolean(navigator.userAgent.match(/.*(iphone|ipod|android|symbian|nokia|blackberry| rim |opera mini|opera mobi|windows ce|windows phone|up\.browser|netfront|palm-|palm os|pre\/|palmsource|avantogo|webos|hiptop|iris|kddi|kindle|lg-|lge|mot-|motorola|nintendo ds|nitro|playstation portable|samsung|sanyo|sprint|sonyericsson|symbian).*/i) || navigator.userAgent.match(/alcatel|audiovox|bird|coral|cricket|docomo|edl|huawei|htc|gt-|lava|lct|lg|lynx|mobile|lenovo|maui|micromax|mot|myphone|nec|nexian|nook|pantech|pg|polaris|ppc|sch|sec|spice|tianyu|ustarcom|utstarcom|videocon|vodafone|winwap|zte/i));
       }
       //移动端排除ipad
       if(sp_isMobile()&&location.search.indexOf(pc=true)==-1&&navigator.userAgent.indexOf(iPad)==-1) {
             //添加meta 方便移动端获取document.documentElement.clientWidth
          document.write(<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />);
       
          if(document.documentElement.clientWidth>760){
              location.href="http://www.xxxx.com/index.shtml?pc=true";
          }else{
              location.href="http://u.pa.com/upingan/upingan/index.html?mediasource=SC03-Direct-00002";
          }

       }
    </script>

 

js判断移动终端url跳转

标签:

原文地址:http://www.cnblogs.com/iicoo/p/5074626.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!