-
Notifications
You must be signed in to change notification settings - Fork 298
/
deeplink.html
61 lines (57 loc) · 2.7 KB
/
deeplink.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>DeepLink 测试</title>
<meta id="viewport" name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,minimal-ui">
</head>
<body>
<div>
<a id="J-call-app" href="javascript:;" class="label">立即打开(没有应用下载应用)>></a>
<input id="J-download-app" type="hidden" name="storeurl" value="https://github.com/youlookwhat/MaterialDesign/raw/master/app/release/app-release.apk">
</div>
<div>
<br/><br/>
<a href="will://link/testId?type=1&id=345">立即打开(直接打开)>></a>
<br/><br/>
<a href="will://jingbin.me/deeplink?type=5&id=567">立即打开(打开同一页面的第二种配置)>></a>
</div>
<!--没有应用下载应用-->
<script>
(function(){
var ua = navigator.userAgent.toLowerCase();
var t;
var config = {
/*scheme:必须*/
scheme_IOS: 'will://',
scheme_Adr: 'will://share/520',
download_url: document.getElementById('J-download-app').value,
timeout: 300
};
function openclient() {
var startTime = Date.now();
var ifr = document.createElement('iframe');
ifr.src = ua.indexOf('os') > 0 ? config.scheme_IOS : config.scheme_Adr;
ifr.style.display = 'none';
document.body.appendChild(ifr);
var t = setTimeout(function() {
var endTime = Date.now();
if (!startTime || endTime - startTime < config.timeout + 200) {
window.location = config.download_url;
} else {
}
}, config.timeout);
window.onblur = function() {
clearTimeout(t);
}
}
window.addEventListener("DOMContentLoaded", function(){
document.getElementById("J-call-app").addEventListener('click',openclient,false);
}, false);
})()
</script>
</body>
</html>