-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisibility.html
More file actions
39 lines (32 loc) · 1003 Bytes
/
visibility.html
File metadata and controls
39 lines (32 loc) · 1003 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>inactivejs Basic Example</title>
</head>
<body>
<div id="wrapper"></div>
<script src="../dist/index.js"></script>
<script type="text/javascript">
function addMessage (message) {
console.log(message);
const wrapper = document.getElementById('wrapper');
const msg = document.createElement('p');
msg.innerText = message;
wrapper.appendChild(msg);
}
function onVisible () {
addMessage('tab is visible! ', (new Date()).toString())
}
function onHidden () {
addMessage('tab is hidden! ', (new Date()).toString())
}
new inactivejs({
onVisible: onVisible,
onHidden: onHidden,
});
</script>
</body>
</html>