test2.html
807 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebView Communication</title>
</head>
<body>
<h2>接口测试2</h2>
<div id="resp"></div>
<button onclick="getStorageSync()">获取本地缓存</button>
<a href="/test/test.html">跳转测试1</a>
<br>
<img src="" alt="test" id=testImg>
</body>
<script>
function xeJsBridgeCallback(message) {
let jsonData = JSON.parse(message);
document.getElementById('resp').innerHTML = '<p><strong>响应:</strong> ' + jsonData.data + '</p>';
}
function getStorageSync() {
let message='{ "timestamp": 1, "unique": "123", "cmd": "getStorageSync", "params": {"key":"test1"} }';
xeJsBridge.postMessage(message);
}
</script>
</html>