I need to refresh a page after 10 minutes of inactivity.
What I mean by inactivity : no mouse move and/or no clicks on the body
Here's what I have so far (that piece of code is working fine)
idleTime = 0;
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 10) {
window.location.reload();
}
}
$j(document).ready( function(e) {
var idleInterval = setInterval("timerIncrement()", 60000); // 1 min
$j(this).mousemove(function () {
idleTime = 0;
});
$j(this).click(function () {
idleTime = 0;
});
}
What I dont like here, is the fact that its reseting the timer on every single mousemove event. And Im worried about performance.
What I would like is something like : Check every 2 minutes if the mouse position changed. If yes increment timer. Not sure how to do that.
Any help?