移动端H5识别微信,安卓,ios

识别安卓/ios手机设备,扫描二维码自动识别手机APP下载地址:
https://blog.csdn.net/zjlovety/article/details/21726785

一、如果是微信浏览器,提示弹出层

<div id="JweixinTip">
    <img src="../images/weixin.png">
</div>
var ua = navigator.userAgent;
var isWeixin = !!/MicroMessenger/i.test(ua);
if(isWeixin){
    document.getElementById('JweixinTip').style.display='block';
}
/*点击弹出层上任意位置,隐藏弹出层*/
document.getElementById('JweixinTip').onclick=function(){
    this.style.display='none';
}

二、安卓ios

var Terminal = {
    // 辨别移动终端类型
    platform : function(){
        var u = navigator.userAgent, app = navigator.appVersion;
        return {
            // android终端或者uc浏览器
            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
            // 是否为iPhone或者QQHD浏览器
            iPhone: u.indexOf('iPhone') > -1 ,
            // 是否iPad
            iPad: u.indexOf('iPad') > -1
        };
    }()
根据不同设备跳转不同的链接地址:
var theUrl ="http://download.android.apk"
if(Terminal.platform.iPhone){ //此处为ios更改下载地址,安卓及浏览器等使用安卓的下载地址
    theUrl ="http://download.ios.apk"
}
window.open(theUrl);

猜你喜欢

转载自blog.csdn.net/qq_38021296/article/details/81746387
今日推荐