-
Notifications
You must be signed in to change notification settings - Fork 0
/
page2.html
49 lines (46 loc) · 1.11 KB
/
page2.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
49
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script>
// Allow window to listen for a postMessage
window.addEventListener("message", event => {
// Normally you would check event.origin
// To verify the targetOrigin matches
// this window's domain
const txt = document.querySelector("#txtMsg");
// event.data contains the message sent
txt.value = event.data.phoneNumber
? `Phone Number is ${event.data.phoneNumber}`
: "Not Clicked";
});
function closeMe() {
try {
window.close();
} catch (e) {
console.log(e);
}
try {
self.close();
} catch (e) {
console.log(e);
}
}
</script>
</head>
<body>
<form>
<h1>Recipient of postMessage</h1>
<fieldset>
<input type="text" id="txtMsg" style="width:300px" />
<input
type="button"
id="btnCloseMe"
value="Close me"
onclick="closeMe();"
/>
</fieldset>
</form>
</body>
</html>