test.html
1.0 KB
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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>ThingJS的 Iframe演示</title>
</head>
<body>
<div width="800px">
<button style="position: absolute;top: 15px;left: 15px;width: 75px;" onclick="flyToCar()">飞到小车</button>
<button style="position: absolute;top: 45px;left: 15px;width: 75px;"
onclick="flyToBack()">返 回</button>
<iframe id="testMsg" style="width: 600px;height: 400px;"
src='https://www.thingjs.com/s/aa25e09eae2f73e6ce080d73?params=105b0f77fd24654d4eebc434e9'></iframe>
</div>
<script>
function flyToCar() {
var a = document.getElementById("testMsg");
var msg = {
funcName: 'test'
}
a.contentWindow.postMessage(msg, "*");
}
function flyToBack() {
var a = document.getElementById("testMsg");
var msg = {
funcName: 'test2',
param: "2"
}
a.contentWindow.postMessage(msg, "*");
}
</script>
</body>
</html>