Reputation: 36733
What's the most simple way to detect user inactivity and ask him if he's there?
Basically, after 3 minutes of the user not clicking on anything on the site, I'd like to ask him if he's there. He click's the OK button of a prompt of sorts and the entire page reloads.
Is there a jQuery script for this?
Upvotes: 4
Views: 2077
Reputation: 8058
Here is a jquery plugin "idleTime" that seems designed to do exactly what you need http://paulirish.com/2009/jquery-idletimer-plugin/
Here is a simple implementation:
$.idleTimer(10000);
$(document).bind("idle.idleTimer", function(){
var reload = confirm("Refresh the Page?");
if (reload){
location.reload(true);
}
else{
window.location = "Log Out Url";
}
});
Upvotes: 4