-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoclose.html
42 lines (30 loc) · 1.05 KB
/
autoclose.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
<html>
<head>
<script>
var timeoutInMiliseconds = 6000;
var timeoutId;
function startTimer() {
// window.setTimeout returns an Id that can be used to start and stop a timer
timeoutId = window.setTimeout(doInactive, timeoutInMiliseconds)
}
function doInactive() {
// does whatever you need it to actually do - probably signs them out or stops polling the server for info
alert("Timed out")
}
function resetTimer() {
window.clearTimeout(timeoutId)
startTimer();
}
function setupTimers() {
document.addEventListener("mousemove", resetTimer, false);
document.addEventListener("mousedown", resetTimer, false);
document.addEventListener("keypress", resetTimer, false);
document.addEventListener("touchmove", resetTimer, false);
startTimer();
}
</script>
</head>
<body onload=setupTimers()>
<p>Timer Started v3</p>
</body>
</html>