I want to make a touch screen web kiosk (running Edge) that resets itself after idle timeout. When no one touches the screen for 2 min (for example), it will refresh itself. How can I do this with js? I want to use it on a local html page.
Asked
Active
Viewed 1,718 times
1
-
1Use `setTimeout()` to run the reset function. Add event handlers for the interaction events that clears the old timer and starts a new one. – Barmar Mar 11 '19 at 14:51
-
it seems already answered in https://stackoverflow.com/questions/667555/how-to-detect-idle-time-in-javascript-elegantly – Oleg Bondarenko Mar 11 '19 at 14:53
-
I suspect most public kiosks do this with code outside the browser that restarts the browser, rather than doing it with JavaScript. – Barmar Mar 11 '19 at 14:53
-
To do it right you need to clear all the browsing data, so one user doesn't get the previous user's completions, credit cards, passwords, history, etc. There must be existing packages that are used by all the kiosks in hotels, airports, etc. – Barmar Mar 11 '19 at 14:55
-
Don't try to roll your own if you're not sure of all the details, you'll create a privacy disaster. – Barmar Mar 11 '19 at 14:56
1 Answers
2
This code ended up working for me, tried many others: https://stackoverflow.com/a/39725556/11185656
var idleTime;
$(document).ready(function () {
reloadPage();
$('html').bind('mousemove click mouseup mousedown keydown keypress keyup submit change mouseenter scroll resize dblclick', function () {
clearTimeout(idleTime);
reloadPage();
});
});
function reloadPage() {
clearTimeout(idleTime);
idleTime = setTimeout(function () {
location.reload();
}, 10000);
}

Elor
- 41
- 3