-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
43 lines (43 loc) · 1.22 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script>
var childwin;
const childname = "popup";
function openChild() {
childwin = window.open('http://127.0.0.1:5500/index.html', childname, 'height=300px, width=500px');
}
function GetParameter() {
if(document.getElementById("boolean").checked)
{
switch(document.getElementById("Text2").value)
{
case 0 : return false;
case 1 : return true;
default : return true;
}
} else return true;
}
function sendMessage(){
let msg= JSON.parse(document.getElementById("Text1").value);
console.log(msg);
// In production, DO NOT use '*', use toe target domain
childwin.postMessage(msg,'*')// childwin is the targetWindow
childwin.focus();
}
</script>
</head>
<body>
<form>
<fieldset>
<input type='button' id='btnopen' value='Open child' onclick='openChild();' />
<input type='text' id='Text1'/>
<input type='text' id='Text2'/>
<input type='button' id='btnSendMsg' value='Send Message' onclick='sendMessage();' />
<input type='checkbox' id='boolean' value="boolean"/>
</fieldset>
</form>
</body>
</html>