js打开app 如果app不存在则跳转下载
//打开(下载)App
function openApp(){
var ua = window.navigator.userAgent.toLowerCase();
//微信
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
window.location.href='downLoadForPhone';
}else{//非微信浏览器
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
var loadDateTime = new Date();
window.setTimeout(function() {
var timeOutDateTime = new Date();
if (timeOutDateTime - loadDateTime < 5000) {
window.location = "";//ios下载地址
} else {
window.close();
}
},2000);
window.location = "schema://";
}else if (navigator.userAgent.match(/android/i)) {
var state = null;
try {
window.location = 'schema://';
setTimeout(function(){
window.location= ""; //android下载地址
},500);
} catch(e) {}
}
}
}
————————————————
版权声明:本文为CSDN博主「、不知不觉、」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010394015/article/details/51444744/