0

I am looking for a really simple piece of javascript code that I can add to an html page that senses when a user has been inactive for 30 minutes, pops up a message for 1 minute and logs the user out of a web application if the user doesn't respond to keep the applcation open.

Thanks

gillers322
  • 249
  • 4
  • 17
  • 1
    1) what have you tried? 2) please define what "inactive" means to you (e.g. mouse movement, key pressed...). – Fabrizio Calderan Sep 20 '12 at 08:55
  • check out this question , I think it will help you [How can I detect with JavaScript/jQuery if the user is currently active on the page?][1] [1]: http://stackoverflow.com/questions/1009260/how-can-i-detect-with-javascript-jquery-if-the-user-is-currently-active-on-the-p – Mahmoud Farahat Sep 20 '12 at 08:56
  • So far I have found this bit of code – gillers322 Sep 20 '12 at 09:47
  • The answer below is perfect! And should accept it. Say, you have a server side script that logs out the users. You just bind a call to that script to `idle.idleTimer`.E.g. `$.idleTimer(10000); $(document).bind("idle.idleTimer", function() {window.location = "logout.php";});` – Michele Mar 13 '14 at 08:04

1 Answers1

2

You can try with idleTime

Link : http://paulirish.com/2009/jquery-idletimer-plugin/

Sample :

$.idleTimer(100);
$(document).bind("idle.idleTimer", function()
{
    var reload = confirm("If you refresh your page ?");

    if (reload)
         location.reload(true);
    else
         window.location = "You log Out";

});
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51