finecms判断PC还是移动

Posted hm21

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了finecms判断PC还是移动相关的知识,希望对你有一定的参考价值。

<script type="application/javascript">
    $(function(){
        var MobileUA = (function() {
            var ua = navigator.userAgent.toLowerCase();
            var mua = {
                ios: /ipod|iphone|ipad/.test(ua), //iOS
                IPHONE: /iphone/.test(ua), //iPhone
                IPAD: /ipad/.test(ua), //iPad
                android: /android/.test(ua), //Android Device
                WINDOWS: /windows/.test(ua), //Windows Device
                TOUCH_DEVICE: (‘ontouchstart‘ in window) || /touch/.test(ua), //Touch Device
                MOBILE: /mobile/.test(ua), //Mobile Device (iPad)
                ANDROID_TABLET: false, //Android Tablet
                WINDOWS_TABLET: false, //Windows Tablet
                TABLET: false, //Tablet (iPad, Android, Windows)
                SMART_PHONE: false //Smart Phone (iPhone, Android)
            };
            mua.ANDROID_TABLET = mua.ANDROID && !mua.MOBILE;
            mua.WINDOWS_TABLET = mua.WINDOWS && /tablet/.test(ua);
            mua.TABLET = mua.IPAD || mua.ANDROID_TABLET || mua.WINDOWS_TABLET;
            mua.SMART_PHONE = mua.MOBILE && !mua.TABLET;
            return mua;
        }());
        //SmartPhone
        if (MobileUA.SMART_PHONE && !$.cookie(‘finecms_my_test_code‘)) {
            // 移动端链接地址
            // 跳转首页
            document.location.href = ‘http://m.finecms.net‘;
            //跳转对应当前页的写法
            //document.location.href = ‘{str_replace(‘www.finecms.net‘, ‘m.finecms.net‘, dr_now_url())}‘;
        }
    });

</script>

以上是关于finecms判断PC还是移动的主要内容,如果未能解决你的问题,请参考以下文章

JS判断PC还是移动端打开网页

js判断是移动端还是pc端

Java判断PC端还是移动端

javascript判断是移动端还是pc端

JS判断是PC端还是移动端

怎么用js判断是pc端还是手机端