PC端跳轉到移動端


<link rel="alternate" media="only screen and (max-width:640px)" href="http://m.xiangjibang.com/">

表示只有在屏幕尺寸小於640像素的時候,跳轉移動端

反之,參照以上說明,照樣可以設置大於多少跳轉PC端

 

<script src="http://www.jxsdnt.com/js/uaredirect.js" type="text/javascript"></script>
<script type="text/javascript">uaredirect("http://www.jxsdnt.com/m/");</script>

第一個script  是為了引用百度的js代碼

第二個script就是跳轉到你想要跳轉的wap頁面

 

下面是另一種方法

<script language="javascript">
//跳轉手機網站
var bs={
versions:function(){
var u = navigator.userAgent, app = navigator.appVersion;
return {//移動終端瀏覽器版本信息
trident: u.indexOf('Trident') > -1, //IE內核
presto: u.indexOf('Presto') > -1, //opera內核
webKit: u.indexOf('AppleWebKit') > -1, //蘋果、谷歌內核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐內核
mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/), //是否為移動終端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios終端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android終端或者uc瀏覽器
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否為iPhone或者QQHD瀏覽器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1 //是否web應該程序,沒有頭部與底部
};
}(),
language:(navigator.browserLanguage || navigator.language).toLowerCase()
}
if(bs.versions.mobile){
if(bs.versions.android||bs.versions.iPhone||bs.versions.iPad||bs.versions.ios){
window.location.href="wap/";
}
}
</script>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM