Created
July 7, 2016 07:28
-
-
Save danielt69/6e04c842cc97c508934516644bf87d8d to your computer and use it in GitHub Desktop.
How to Detect user is active or idle on web page Using JQuery ?
From https://arjunphp.com/detect-user-is-active-or-idle-on-web-page-using-jquery/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
var idleState = false; | |
var idleTimer = null; | |
$('*').bind('mousemove click mouseup mousedown keydown keypress keyup submit change mouseenter scroll resize dblclick', function () { | |
clearTimeout(idleTimer); | |
if (idleState === true) { | |
$("body").css('background-color','#fff'); | |
} | |
idleState = false; | |
idleTimer = setTimeout(function () { | |
$("body").css('background-color','#000'); | |
idleState = true; }, 2000); | |
}); | |
$("body").trigger("mousemove"); | |
}); | |
// - See more at: https://arjunphp.com/detect-user-is-active-or-idle-on-web-page-using-jquery/#sthash.p4P2lGUP.dpuf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment