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>