javascript 判断浏览器类型

<script>
function is_Ios(){
var ua = window.navigator.userAgent.toLowerCase(); 
return !!ua.match(/\(i[^]+;? cpu.+mac os x/);
}
function is_Android(){
var ua = window.navigator.userAgent.toLowerCase();
return ua.indexOf('android') > -1 || ua.indexOf('linux') > -1;
}
function is_Weixin(){ 
var ua = window.navigator.userAgent.toLowerCase(); 
return (ua.match(/MicroMessenger/i)=="micromessenger");
}
if(is_Weixin()){
var jsDownload = document.getElementById('js-download');
if(jsDownload.style.display == 'block'){
jsDownload.style.display="none";
}else{
jsDownload.style.display = "block";
}
}else if(is_Ios()){
// document.getElementById('btnDown').href = '/app/down/0/ios';
document.getElementById('btnDown').href = 'itms-services://?action=download-manifest&url=https://www.leyouss.com/app/down/0/ios';
}else if(is_Android()){
document.getElementById('btnDown').href = '/app/down/0/android';
}
</script>

ps:参考

http://www.douban.com/note/348261828/


转载于:https://my.oschina.net/jack088/blog/514379

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值