冰豆网

分享网络精彩
bingdou.com.cn

帝国CMS全站电脑端自动调整手机端动态静态代码

时间:2019-07-19加入收藏

手机端访问电脑端网页自动跳转至手机端:
页面头部

JS代码在body前面加上以下HTML源代码

<script type="text/javascript"> try {var urlhash = window.location.hash;if (!urlhash.match("fromapp")) {if ((navigator.userAgent.match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i))) {window.location="`http://m.bingdou.net/`";}}} catch(err) { }</script>
<meta name="mobile-agent" content="format=xhtml;url=`http://m.bingdou.net/`">

列表页

动态页:http://m.bingdou.net/e/action/ListInfo/?classid=[!--self.classid--]
静态页:http://m.ppqq.net<?$r['classid']=$GLOBALS[navclassid];$classurl=sys_ReturnBqClassname($r,9);echo $classurl;?>

内容页

动态页:http://m.bingdou.net/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]
静态页:http://m.bingdou.net[!--titleurl--]

分成动态与静态页面,可自行选择更换bingdou.net为自己的子域名。

 

电脑端访问手机端网页自动跳转至电脑端:
页面头部

JS代码在body前面加上以下HTML源代码

<script type="text/javascript">
        var dynamicLoading = {
          css: function(path){
         if(!path || path.length === 0){
          throw new Error('argument "path" is required !');
         }
         var head = document.getElementsByTagName('head')[0];
            var link = document.createElement('link');
            link.href = path;
            link.rel = 'stylesheet';
            link.type = 'text/css';
            head.appendChild(link);
          },
          js: function(path){
         if(!path || path.length === 0){
          throw new Error('argument "path" is required !');
         }
         var head = document.getElementsByTagName('head')[0];
            var script = document.createElement('script');
            script.src = path;
            script.type = 'text/javascript';
            head.appendChild(script);
          }
        }
        function getCookie(name)
        {
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg))
        return unescape(arr[2]);
        else
        return null;
        }
        function setCookie(name,value)
        {
        var Days = 30;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
        }
        function change(type){
            setCookie('allmobile',type);
            window.location.reload();
        }
        
        function initPage(){
          var type = getCookie('allmobile');
          if(type == undefined || type == null){
           //根据屏幕大小显示对应样式
            var sUserAgent = navigator.userAgent.toLowerCase();  
            var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";  
            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 (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM)             {  
            }else{
                window.location.href="http://www.bingdou.net/";
            }
          }
          else if(type == 'desktop'){
         $("#return_iphone").css("display","block !important");
            window.location.href="http://www.bingdou.net/";
          }else if(type == 'mobile'){
          }
        }
    initPage();
    </script>

打 赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

TGA: jquery

分享到:


官方微信二维码冰豆网官方微信公众号