-
Notifications
You must be signed in to change notification settings - Fork 0
/
JavaScript-Bridge.html
43 lines (41 loc) · 1.27 KB
/
JavaScript-Bridge.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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
<title>WebView JavaScript Bridge 通用测试脚本</title>
</head>
<body>
<noscript>当前 JavaScript 不可用</noscript>
<div id="init"></div>
<img src="http://image/file:///storage/emulated/0/0000/0.jpg" width="80%"
alt="http://image/file:///storage/emulated/0/0000/0.jpg">
</body>
<script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
new VConsole();
const browser_bridge = {
init() {
//初始化方法
console.log('init');
return '当前桥接对象:Browser'
},
debug() {
//调试方法
console.log('debug');
},
};
console.log('window.bridge: ' + window.bridge);
if (window.bridge === undefined) {
window.bridge = browser_bridge;
}
Object.keys(browser_bridge).forEach(key => {
if (window.bridge[key] === undefined) {
window.bridge[key] = browser_bridge[key];
}
});
window.bridge.debug();
$('#init').html(window.bridge.init());
</script>
</html>