-
Notifications
You must be signed in to change notification settings - Fork 0
/
sbs.html
42 lines (39 loc) · 1.15 KB
/
sbs.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
<!DOCTYPE html>
<html style="height:99%; margin: 0;">
<body style="width: 100%; height: 100%; margin: 0; display: flex;">
</body>
<script>
var urlParams = new URLSearchParams(window.location.search);
const iframes = []
const body = document.getElementsByTagName('body')[0];
var sync = true;
urlParams.forEach((value, key) => {
console.log(key, ',', value);
if (!value) {
value = key;
const iframe = document.createElement('iframe');
iframe.src = `./${value}.html`;
iframe.width = "100%";
iframe.height = "100%";
iframe.style.border = "none";
iframes.push(iframe);
const div = document.createElement('div')
div.style = "flex-grow: 1;";
div.append(iframe)
body.append(div);
} else if (key === "sync") {
sync = value === "true";
}
})
console.log(sync);
if (sync) {
window.addEventListener("message", event => {
iframes.forEach(iframe => {
if (iframe.contentWindow !== event.source) {
iframe.contentWindow.postMessage(event.data, '*');
}
})
})
}
</script>
</html>