js区分苹果浏览器和安卓浏览器

<script type="text/javascript">
    jQuery(function($){
        var $js_footer_top=$("#js_footer_top");
        var $js_iphone=$("#js_iphone");
        var $js_android=$("#js_android");
        if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
            if (document.cookie.indexOf("iphone_redirect=false") == -1)
            {
                $js_footer_top.show();
                   $js_iphone.show();
                $js_android.hide();
            }
        }
        var ua = navigator.userAgent.toLowerCase();
        var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
        if(isAndroid) {
            $js_footer_top.show();
            $js_android.show();
            $js_iphone.hide();
        }
    })
    </script>

相关推荐