forked from Shahoriar3254/test_of_3dVista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-as-iframe.html
36 lines (36 loc) · 998 Bytes
/
test-as-iframe.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
<html>
<head>
<title>Test as iframe</title>
</head>
<body>
<h1>Test as iframe</h1>
<p>Test as iframe</p>
<iframe
id="test-frame"
src="/index.html"
style="width: 100vw; height: 100vh"
></iframe>
<button id="send-test-data">send test data</button>
<script>
// listen for messages from the child iframe
window.addEventListener('message', function (event) {
console.log('[Iframe] Parent received message:', event.data)
})
document.addEventListener('DOMContentLoaded', function () {
document
.getElementById('send-test-data')
.addEventListener('click', function () {
var iframe = document.getElementById('test-frame')
iframe.contentWindow.postMessage(
{
type: 'navigate',
route: '',
data: 'test data',
},
'*'
)
})
})
</script>
</body>
</html>