js跳转手机端
<script> var host = window.location.protocol+'//'+window.location.host+'/'; //获取当前域名 var host_wap = window.location.protocol+'//'+window.location.host+'/wap/'; //要跳转的手机端地址,这里写的是wap/ console.log(host) console.log(host_wap) //电脑端跳转手机端 var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "UCBrowser", "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; //alert(mobileAgent[i]); var url = window.location.href; location.href =url.replace( host, host_wap );//跳转手机端的网址 break; } } </script>