-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.html
37 lines (29 loc) · 1.24 KB
/
frame.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iFRAME only</title>
</head>
<body style="background-color:rgb(222,222,222);">
<h3>If you click inside this framed window you will see that the change is detected by only blur/focus. You may click outside and inside it again to repeat the test.</h3>
<script type="text/javascript">
document.addEventListener("visibilitychange", visChngF);
function visChngF() {
if (document.hidden) {
top.console.log("Msg from frame:\nUSER IS GONE FROM FRAME: Detected by visibilitychange event in frame");
} else {
top.console.log("Msg from frame:\nUSER HAS COME BACK TO FRAME: Detected by visibilitychange event in frame");
}
}
window.addEventListener('blur', blurHappenedF);
function blurHappenedF() {
top.console.log("Msg from frame:\nUSER IS OUT OF FRAME: Detected by blur event in frame");
}
window.addEventListener('focus', focusHappenedF);
function focusHappenedF() {
top.console.log("Msg from frame:\nUSER IS IN FRAME: Detected by focus event in frame");
}
</script>
</body>
</html>