• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

控制pc端和手机端显示不同的页面

互联网 diligentman 3小时前 2次浏览

《直接添加下方代码至index首页代码最上方》

<script type="text/javascript">  
    var userAgent = navigator.userAgent.toLowerCase();     
    var platform;     
    if(userAgent == null || userAgent == '')
    { 
  platform = 'WEB'; location.href = "http://www.0451huishou.cn/";
     }else{ 
  if(userAgent.indexOf("android") != -1 )
     { 
    platform = 'ANDROID';
    location.href = "http://www.0451huishou.cn/3g/"; 
      }else if(userAgent.indexOf("ios") != -1 || userAgent.indexOf("iphone") 

!= -1 || userAgent.indexOf("ipad") != -1)
  { 
    platform = 'IOS';
    location.href = "http://www.0451huishou.cn/3g/";
   }else if(userAgent.indexOf("windows phone") != -1 )
       {
    platform = 'WP';
    location.href = "http://www.0451huishou.cn/3g/";
        } 
     } 
</script>

《注意更换为自己的域名,并且把手机端的页面代码放在根目录先命名“3g”》

                                                                                                                                                

                                                                                                                                              供参考


程序员灯塔
转载请注明原文链接:控制pc端和手机端显示不同的页面
喜欢 (0)