js实现网页自动跳转到手机页面

网站既包含PC端页面,又包括手机端页面时,打开手机端自动跳转手机页面,js代码如下:

<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; location.href = '#'; break; } } </script>

 

posted on 2018-01-04 14:56  柳暗花明8963  阅读(3479)  评论(0编辑  收藏  举报