唤醒app以非微信为例

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="app">13212313133213321212323</div>
</body>
<script type="text/javascript">
var btn = document.getElementById('app')
btn.onclick = function(){
openApp()
}
function openApp(){
var ua = window.navigator.userAgent.toLowerCase();
//微信
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
window.location.href='###'; //微信浏览器要做处理
}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 = "http://www.baidu.com";//ios下载地址
} else {
window.close();
}
},25);
window.location = "weixin://"; //iosapp配置地址
}else if (navigator.userAgent.match(/android/i)) {
var state = null;
try {
window.location = 'weixin://'; //安卓app配置地址
setTimeout(function(){
window.location= "http://www.baidu.com"; //android下载地址

},500);
} catch(e) {}
}
}
}
</script>
</html>

posted @ 2017-08-01 09:52  missJun  阅读(704)  评论(0编辑  收藏  举报