h5页面打开APP

时间:2022-11-18 19:13:09

本人亲自试验过了说可以的

代码如下:

<script type="text/javascript">
document.getElementById('openApp').onclick = function(e){
if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
window.location.href = "apphaha://";//ios app协议
window.setTimeout(function() {
window.location.href = "商店下载地址";
}, 2000)
}
if(navigator.userAgent.match(/android/i)){
window.location.href = "app://main";//android app协议
window.setTimeout(function() {
window.location.href = ".apk";//android 下载地址
}, 2000)
}
};
</script>
<a href="javascript:;" id="openApp">我是APP</a>

微信上没能实现打开一些APP的,望大神指教!!!