-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path12.html
35 lines (31 loc) · 843 Bytes
/
12.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
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<title>TIMER EXAMPLE</title>
<script>
function print(e, m) {
document.getElementById(e).innerHTML += `<div>${m}</div>`;
}
const doAfter = (i, f) => { return window.setTimeout(f, i) };
const doEvery = (i, f) => { return window.setInterval(f, i) };
window.onload = () => {
let i = doEvery(500, () => {
print("event_log", "doEvery triggered");
});
doAfter(3000, () => {
print("event_log", "doAfter triggered");
doAfter(2000, () => {
window.clearInterval(i);
print("event_log", "doEvery cancelled");
});
});
}
</script>
</head>
<body>
<h1>TIMER EXAMPLE</h1>
<h2>Timer Events</h2>
<div id='event_log'></div>
</body>
</html>