手机端页面访问PC页面自动跳手机端代码
<script> 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 = 'http://www.baidu.com'; break; } }
</script>
<script type="text/javascript"> (function() { var sUserAgent = navigator.userAgent; if (sUserAgent.indexOf('Android') > -1 || sUserAgent.indexOf('iPhone') > -1 || sUserAgent.indexOf('iPad') > -1 || sUserAgent.indexOf('iPod') > -1 || sUserAgent.indexOf('Symbian') > -1) { location.href = 'http://www.baidu.com'; } else {} })(); </script>
两个都可以试试