tags:

views:

110

answers:

3

if you are inactive on gmail, by not moving your mouse for a while, it changes your chat status to orange which means idle. but when you start moving the mouse again it turns it back to green meaning active. how does it know when you are moving your mouse?

+5  A: 

without checking, I'd say this is done with an onmousemove event handler attached to the whole document.

DDaviesBrackett
with some setTimeout or setInterval!
thephpdeveloper
A: 

google is watching us all the time! As I type these words they already know!

CharlesM
+1  A: 

You can attach an "onmousemove" event to the Javascript "document" object, which is triggered every time the mouse moves across the browser window. It's a simple task to reset a timer whenever this happens, and if the timer goes off without any movement detected, it will set your status to "idle". When the onmousemove function is next called, it will set your status back to "available".

Example with full code: http://www.codeguru.com/forum/archive/index.php/t-433956.html

Nick