帝国cms判断PC端跳转手机端方法,亲测可用。
首先新建一个JS文件,复制以下代码
1
2
3
4
5
6
7
8
9
10
11
12
|
function browserRedirect(url) { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os" ; var bIsMidp = sUserAgent.match(/midp/i) == "midp" ; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4" ; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb" ; var bIsAndroid = sUserAgent.match(/android/i) == "android" ; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce" ; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile" ; if (bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM){ window.location.replace(url); } |
然后再需要跳转的页面,复制以下对应代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<!--帝国CMS首页M站跳转--> < script src = 'http://www.cydidc.com/wap.js' language = 'javascript' ></ script > < script type = "text/javascript" > browserRedirect("http://www.cydidc.com/"); </ script > <!--帝国CMS封面页M站跳转--> < script src = 'http://www.cydidc.com/wap.js' language = 'javascript' ></ script > < script type = "text/javascript" > browserRedirect("http://www.cydidc.com/e/public/ClassUrl/?classid=[!--self.classid--]"); </ script > <!--帝国CMS列表页M站跳转--> < script src = 'http://www.cydidc.com/wap.js' language = 'javascript' ></ script > < script type = "text/javascript" > browserRedirect("http://www.cydidc.com/e/public/ClassUrl/?classid=[!--self.classid--]"); </ script > <!--帝国CMS内容页跳转--> < script src = 'http://www.cydidc.com/wap.js' language = 'javascript' ></ script > < script type = "text/javascript" > browserRedirect("http://www.cydidc.com/[!--titleurl--]"); </ script > |
记得将以上代码中域名、路径替换成你的域名、文件路径。