0
With this code, the page redirects after 5 minutes if there is no action, and this only happens in refresh or when changing pages, but, intended that the counter reset the movement of the mouse and keyboard instead of in the action of the page itself.
function CountDown(duration, display) {
if (!isNaN(duration)) {
var timer = duration, minutes, seconds;
var interVal= setInterval(function () {
minutes = parseInt(timer / 60, 10);
seconds = parseInt(timer % 60, 10);
minutes = minutes < 10 ? "0" + minutes : minutes; seconds = seconds < 10 ? "0" + seconds : seconds;
$(display).html("<b>" + minutes + "m : " + seconds + "s" + "</b>");
if (--timer <= 0) {
timer = duration;
SubmitFunction();
$('#div').empty();
clearInterval(interVal)
}
},1000);
}
}
function SubmitFunction(){
$(location).attr('href', 'https://answall.com');
}
CountDown(300,$('#div'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="div"></div>
not only the answer but also the explanation.
– Groot