zoukankan      html  css  js  c++  java
  • 一分钟教你解决前端分流问题

      我们在开发的时候总会遇到这样的问题,你的电脑能正常的打开一个网站,但是到了手机上他就乱套了,着实让人看着心烦。现在不怕了,哥哥我教你一招巧妙解决你的繁闹,实现不同端口平台精确分流引流。

      废话不说下面先上一段代码:完全是我的实战干货

      

    <script type="text/javascript">  
    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|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
                    window.location.href="http://www.xxxxx.com/mobile/index.html";
                }else if(/iPad/i.test(navigator.userAgent)){
                }else{
                    window.location.href="http://www.xxxxx.com/index.html"
                }
            }catch(e){}
        }
    } 
    </script>

    在发布好的网站上的首页中加入上面的这段代码你就可以快速的将手机端访问网站的流量引入到手机端,平板端,等等。

  • 相关阅读:
    Ubuntu
    VSCode
    VSCode
    Astyle
    Qt
    待办
    Qt
    Qt
    Qt
    python pip常用命令、配置pip源
  • 原文地址:https://www.cnblogs.com/qianxiaoruofeng/p/8403516.html
Copyright © 2011-2022 走看看