0
Good afternoon guys, I’m trying to get my site back to home automatically after a while in wordpress, I researched a lot and got this script, it also Zera the count if the mouse is used or the keyboard.
<script type="text/javascript">
var idleTime = 0;
$(document).ready(function() {
//Increment the idle time counter every minute.
var idleInterval = setInterval(timerIncrement, 60000); // 1 minute
//Zero the idle timer on mouse movement.
$(this).mousemove(function(e) {
idleTime = 0;
});
$(this).keypress(function(e) {
idleTime = 0;
});
});
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 4) { // 5 minutes
window.location.href = "www.exemplo.com.br"
}
}
however for some reason I did not find it does not work, but if I do in a normal html it works, can help me?
Hello Jefferson, Is any javascript error displayed on the console when you run this code? If not displayed, you can add a.log('Idletime: ', idleTime) console within the timerIncrement function to check if it is being called, this can help determine the nature of the error.
– ooredroxoo
So, no mistake appears, I’ll try to do what you said, thank you!
– Jefferson Matos