-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathcross-origin.html
More file actions
40 lines (36 loc) · 934 Bytes
/
cross-origin.html
File metadata and controls
40 lines (36 loc) · 934 Bytes
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
<html>
<head>
<style>
body {
background-color: skyblue;
margin: 2px;
}
</style>
</head>
<body>
<div>
<span>iframe origin:</span>
<span id="iframe-origin"></span>
</div>
<div>
<span>parent origin:</span>
<span id="parent-origin"></span>
</div>
<script>
document.getElementById('iframe-origin').textContent = window.origin;
const url = new URL(location.href);
const parentOrigin = url.searchParams.get('parentorigin');
document.getElementById('parent-origin').textContent = parentOrigin;
setTimeout(async () => {
await new Promise((resolve) => {
setTimeout(() => {
parent.postMessage('88', parentOrigin);
resolve();
});
});
});
const crossOriginCookie = document.cookie;
localStorage.setItem('mph', '88');
</script>
</body>
</html>