判断移动端wap端还是pc

https://www.cnblogs.com/wangjing-web/p/11840496.html
https://www.cnblogs.com/mbyund/p/6406004.html

  <script>
        (function(){
            var bp = document.createElement('script');
            var curProtocol = window.location.protocol.split(':')[0];
            if (curProtocol === 'https') {
                bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
            }
            else {
                bp.src = 'http://push.zhanzhang.baidu.com/push.js';
            }
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(bp, s);

            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?1adbb9e6d386abafb2e3edc95ac533e1";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>
    <script>
        /*判断是否来自wap*/
        if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
            window.location.href = "https://m.dgg.cn";
        }
        var _hmt = _hmt || [];
    </script>
    
<script type="text/javascript">
try{
    if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
        window.location.href="mindex.html";
    }else{
        window.location.href="cindex.html";
    }
}catch(e){}
</script>
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页