码迷,mamicode.com
首页 > 移动开发 > 详细

finecms判断PC还是移动

时间:2018-12-30 12:49:01      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:fine   ret   use   tar   function   ref   ipa   mobile   cti   

<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还是移动

标签:fine   ret   use   tar   function   ref   ipa   mobile   cti   

原文地址:https://www.cnblogs.com/hm21/p/10198988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!