2

站长博客:https://www.pipipi.net/

PC判断是否为手机,代码如下

    <script type="text/javascript">
        !function () {
            function params(u, p) {
                var m = new RegExp("(?:&|/?)" + p + "=([^&$]+)").exec(u);
                return m ? m[1] : '';
            }
            if (/iphone|android|ipod/i.test(navigator.userAgent.toLowerCase()) == true && params(location.search, "from") != "mobile") {
                location.href = '';
            }
        }();
    </script>

移动端判断是否为PC,代码如下

  <script type="text/javascript">
        ! function() {
            if (/iphone|android|ipod/i.test(navigator.userAgent.toLowerCase()) == false) {
                location.href = '';
            }
        }();
        document.documentElement.style.fontSize = document.documentElement.clientHeight/document.documentElement.clientWidth<1.5 ? (document.documentElement.clientHeight/603*312.5+"%") : (document.documentElement.clientWidth/375*312.5+"%");
    </script>

犀牛前端部落
118 声望2 粉丝

犀牛前端部落: