点击的时候默认打开app,如果2秒钟没有打开,就跳转到下载地址
document.getElementById('openApp').onclick = function(e){
if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i))
{
window.location.href = "com.baidu.tieba://";//ios app协议
window.setTimeout(function() {
window.location.href = "https://itunes.apple.com/cn/app/id477927812";//Ios下载地址
}, 2000)
}
if(navigator.userAgent.match(/android/i))
{
window.location.href = "com.baidu.tieba://app";//android app协议
window.setTimeout(function() {
window.location.href = "https://****.apk";//android 下载地址
}, 2000)
}
};