如何让织梦系统dedecms,PC端跳转移动端?
以下为示例代码:
首页:
<meta name=”mobile-agent” content=”format=html5;url={dede:global.cfg_mobileurl/}/index.php”>
<meta name=”mobile-agent” content=”format=xhtml;url={dede:global.cfg_mobileurl/}/index.php”>
列表页:
<meta name=”mobile-agent” content=”format=html5;url={dede:global.cfg_mobileurl/}/list.php?tid={dede:field.id/}”>
<meta name=”mobile-agent” content=”format=xhtml;url={dede:global.cfg_mobileurl/}/list.php?tid={dede:field.id/}”>
详情页:
<meta name=”mobile-agent” content=”format=html5;url={dede:global.cfg_mobileurl/}/view.php?aid={dede:field.id/}”>
<meta name=”mobile-agent” content=”format=xhtml;url={dede:global.cfg_mobileurl/}/view.php?aid={dede:field.id/}”>
js判断终端的代码:
<script type=”text/javascript”>if(window.location.toString().indexOf(‘pref=padindex’) != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf(“?mobile”)<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href=”{dede:global.cfg_mobileurl/}/index.php” rel=”external nofollow” ;}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>
文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/114839.html<