js判断PC端 移动端 并跳转到对应页面


一、PC端跳转到移动端

 html页面:

<script>var webroot="/",catid="{$catid}",murl="m/{$catdir}.html";</script> 
<script src="{JS_PATH}ql/mobile.js"></script>    

mobile.js文件:

if((navigator.userAgent.toLowerCase().match(/(iPhone|iPod|Android|ios)/i))){if(typeof(murl)=="undefined"){var murl="";}location.href=webroot+murl;}

 

二、移动端跳转到PC端

 html页面:

<script>var webroot="/",catid="{$catid}",murl="{$catdir}.html";</script> 
<script src="{JS_PATH}wap/pc.js"></script>        

pc.js文件:

  var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;

        if (is_mobi) {

           // window.location.href = "mobile.html";

        }else{

            window.location.href=webroot+murl;

        }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM