判断ios还是android

复制代码
$(function(){
    var u = navigator.userAgent;
    var ua = navigator.userAgent.toLowerCase();
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if(ua.match(/MicroMessenger/i)=="micromessenger") {   //微信内置浏览器+应用宝链接
        $(".download a").bind('touchstart', function (event) {
            window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=应用名 '
        });
    }else{
        if(isiOS){
            $(".download a").bind('touchstart', function (event) {
                window.location.href='https://itunes.apple.com/cn/app/应用名'
                 
            });
        }else if(isAndroid){
            $(".download a").bind('touchstart', function (event) {
                window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=应用名'
                 
            });
        }else{  //PC 端
            $(".download a").click(function(){
                window.location.href='应用链接'
            });
        }
     
    }
     
});
复制代码
posted @ 2017-09-26 20:19  王思聪6  阅读(155)  评论(0编辑  收藏  举报
友情链接:回力球鞋 | 中老年高档女装