织梦移动端与pc之间的相互跳转,直接把js放到页面,然后把当前的网址写入browserRedirect()中去,m端要注意列表页用list.php文章页用view.php
代码语言:javascript复制<script type="text/javascript">
window.onload = function() {
//输入当前网址,执行方法去判断
browserRedirect("{dede:global.cfg_basehost/}/m/list.php?tid={dede:field.id/}");
}
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) {
//移动端
} else {
//PC端
var c = {dede:field.id/};
//移动端列表页跳pc列表页
window.location.replace("{dede:global.cfg_basehost/}{dede:type typeid='" c "' row=1}[field:typelink /]{/dede:type}");
//移动端内容页跳pc内容页
window.location.replace("{dede:global.cfg_basehost/}{dede:field.id runphp='yes'}$id=@me; @me='';$url=GetOneArchive($id); @me=$url['arcurl'];{/dede:field.id}");
}
}
</script>