首页 > 代码库 > 用JS如何判断打开网页的是安卓还是ios

用JS如何判断打开网页的是安卓还是ios

<script type = "text/javascript">
$(function(){
    var ua = navigator.userAgent.toLowerCase();
    if (/iphone|ipad|ipod/.test(ua)) {
      $("a").attr("href","https://itunes.apple.com/us/app/ren-ren-duo-bao-yi-ge-shou/id1111430715?l=zh&ls=1&mt=8"); 
    } else {
          $("a").attr("href","http://www.rrdb8.com/statics/templates/app/RenRenDuoBao.apk"); 
    }
})
</script>

用JS如何判断打开网页的是安卓还是ios