-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframeC.html
47 lines (47 loc) · 1.49 KB
/
frameC.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
<!--
* @Author: caizeyong
* @Date: 2019-11-06 16:45:07
* @Description:
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>frame c</title>
</head>
<body>
<div>
dynamic load page and get data from other page: <span id="j_sum"></span>
</div>
<div>
root frames count: <span id="j_count"></span>
</div>
<script src="./eventBus.js"></script>
<script>
var registed = false
CreatePostMessageEventBus({
success: function () {
registed = true
console.log('注册成功')
this.send({
name: 'root_get-frames-count'
})
},
receive: function (data) {
console.log('接收到数据', data)
if (data.name === 'change') {
document.querySelector('#j_sum').innerText = data.sum
} else if (data.name === 'root_frames-count') {
document.querySelector('#j_count').innerText = data.count
}
},
request: function (cmd) {
console.log('要求派发事件', cmd)
},
on: ['change','root_frames-count']
})
</script>
</body>
</html>