jquery判断iPhone、Android设备类型
最近做了一版微信宣传页,通过JQ来判断设备,并进行下载
微信内置浏览器对下载链接进行了屏蔽,所以先进行判断,如果是微信内置浏览器,则跳转应用宝链接,如果不是,则判断是iPhone/Adroid/PC 并进行跳转
代码如下:
function downloadApp(){ 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").click(function(){ window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=应用名 ' }); }else{ if(isiOS){ $(".download a").click(function(){ window.location.href='https://itunes.apple.com/cn/app/应用名' }); }else if(isAndroid){ $(".download a").click(function(){ window.location.href='http://a.app.qq.com/o/simple.jsp?pkgname=应用名' }); }else{ $(".download a").click(function(){ window.location.href='应用链接' }); } } }
相关推荐
liuxudong00 2020-11-19
leitingdulante 2020-10-21
xuegangic 2020-10-17
章鱼之家 2020-10-29
硬币0 2020-10-15
ZuoYanDeHuangHun 2020-09-18
chsoft 2020-09-17
MatrixHero 2020-08-20
XxZproject 2020-08-10
定格 2020-08-15
Mryiyi 2020-08-07
ydc0 2020-07-30
yechen00 2020-07-25
孝平 2020-07-18
ntfsformac 2020-06-23
好好学习天天 2020-06-12
Charliewolf 2020-06-05
MAC2007 2020-06-04
fanxiaoxuan 2020-06-03