blog post

When the user goes idle, and when the user comes back. Set the idle period on the third line, 1000 = 1 second.

idleTimer = null;
idleState = false;
idleWait = 2000;

(function ($) {

    $(document).ready(function () {
        $('*').bind('mousemove keydown scroll', function () {
            if (idleState == true) { 
                // Reactivated event

Welcome Back.

"); } idleState = false; idleTimer = setTimeout(function () { // Idle Event $("body").append("

You've been idle for " + idleWait/1000 + " seconds.

"); $('body').trigger("mousemove"); idleState = true; }, idleWait); }); $("body").trigger("mousemove"); }); }) (jQuery)

his works by using a setTimeout function to fire at the end of the specified seconds. If basically anything happens during that time (the mouse moves, the page is scrolled, or a key is pressed) the timeout period is reset.

  • Share This Story

Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla

I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Comments (4)

  • Curtiswory

    Thursday, 17 August, 2017 09:52 AM

    Nice and keep it up

  • Anuj

    Wednesday, 25 January, 2017 05:47 PM

    Nice effort :)

  • Curtiswory

    Tuesday, 24 January, 2017 04:07 AM


  • RichardOt

    Thursday, 12 January, 2017 05:21 AM


Leave a comment


Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email


Style Switcher

Change Color

×! We use cookies to improve your user experience. More information