-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (50 loc) · 2.33 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
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PARENT AND FRAME</title>
<link rel="icon" type="image/png" href="icon.png" id="icon" sizes="16x16">
<style media="screen">
a{ text-decoration: none; color: lightskyblue; }
a:hover{ color: lightsalmon; }
a:active { color: darkturquoise; }
a:visited { color: lightskyblue; }
h5{color: lightsteelblue;}
h4{color: steelblue;}
</style>
</head>
<body>
<h4>Testing <li>document » visibilitychange</li> versus <li>window » blur/focus</li></h4>
<h5>Either use your browser's native console or click the gear icon before you start navigating around</h5>
<h1>This header exists in the parent window</h1>
<iframe src="frame.html" width="500" height="150" style="border:1;"></iframe>
<br><br>
<h3>Also try minimizing and maximizing the browser window or changing the browser tab. You will see that the result will depend on whichever window had <i>the focus</i>.</h3>
<h4>Refresh the tab or clear the console to start over if things get confusing.</h4>
<br><br>
<h5>Start enhancing your personal <strong>i18n!</strong> <br>Use <a href="https://speakworldlanguages.github.io/" target="_blank">speakworldlanguages.app</a></h5>
<script type="text/javascript">
document.addEventListener("visibilitychange", visChngF);
function visChngF() {
if (document.hidden) {
console.log("Msg from parent:\nUSER IS GONE FROM PARENT: Detected by visibilitychange event in parent");
} else {
console.log("Msg from parent:\nUSER HAS COME BACK TO PARENT: Detected by visibilitychange event in parent");
}
}
window.addEventListener('blur', blurHappenedF);
function blurHappenedF() {
console.log("Msg from parent:\nUSER IS NOW AWAY FROM PARENT: Detected by blur event in parent");
}
window.addEventListener('focus', focusHappenedF);
function focusHappenedF() {
console.log("Msg from parent:\nUSER IS NOW HERE IN PARENT: Detected by focus event in parent");
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/eruda/3.0.1/eruda.min.js" onload="eruda.init();"></script>
<!--
<script>eruda.init();</script>
-->
</body>
</html>