Skip to content Skip to sidebar Skip to footer

Javascript To Detect Inactive Or Away User

Is there any standard way of detecting when a user is away or not looking at the webpage? Something similar to this library. For example, I want to trigger an event if there is no

Solution 1:

I would add 'blur' and 'focus' handlers to the window to detect when the user changed tabs. On blur, the user is deemed inactive.

Then for actual activity I would attach mouseMove and keyDown event handlers to the document (capture phase mode), every time they fired I would reset a timer. When the timer elapsed the user is deemed to be inactive.

Post a Comment for "Javascript To Detect Inactive Or Away User"