This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (45 loc) · 1.52 KB
/
index.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
48
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p id="para"> </p>
<div id="myElement"></div>
<script src="./dist/communicator.js" charset="utf-8"></script>
<script>
let lsf;
let children = [];
function registerStuff() {
lsf = new LocalStorageCommunicator();
let winId = Math.random();
children.push(winId);
lsf.registerFunction("ChangePara", function (mes) {
const now = Date.now();
const diff = now - mes.time;
console.log(mes, diff, now);
var pa = document.getElementById("para");
pa.innerHTML += mes.p + " from " + mes.winId;
return "Changed paragraph to " + mes.p;
});
var p = document.getElementById("myElement");
var a = document.createElement('a');
a.setAttribute('href', "mypage.html#" + winId);
a.setAttribute('rel', "noreferrer");
a.setAttribute('target', "_blank");
p.appendChild(a);
a.click();
}
window.addEventListener('load', registerStuff);
function btnClick() {
// not working
for (let i = 0; i < children.length; i++) {
const element = children[i];
lsf.callFunction("CloseChild", element);
}
}
</script>
<button type="button" onclick="btnClick()">Close children (Not working)</button>
</body>
</html>