---
title: "js区分苹果浏览器和安卓浏览器"
author: "水果硬糖"
date: "2014-06-17T15:08:30Z"
tags: []
categories: ["移动开发"]
slug: "js"
draft: false
lastmod: "2014-06-17T15:08:30Z"
id: 2081489
url: "https://fruithardcandy.iteye.com/blog/2081489"
---

```
<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>
```