admin管理员组

文章数量:1287983

How Facebook detects your away state (you know, the half moon in the chat window)? How you can check in Javascript if a person is away from your page, even if it's open in the browser? Do you think there is any library that already does it?

How Facebook detects your away state (you know, the half moon in the chat window)? How you can check in Javascript if a person is away from your page, even if it's open in the browser? Do you think there is any library that already does it?

Share Improve this question asked Aug 7, 2009 at 17:15 Patrizio RulloPatrizio Rullo 4711 gold badge4 silver badges13 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 9

JQuery idleTimer plugin

They have JavaScript which runs every 30-60 seconds and reports back, plus they know if you're browsing to other pages on the site, which would reset the counter.

Note, if you open up Facebook, and then browse another site and never go back to the Facebook tab, you'll be 'away'

This is probably implemented with a idle timeout as discussed here on SO and on other websites.

I would guess that on each request they set a variable that is last activity time. Then they would query that value using AJAX and after a specific amount of time, you are considered "away".

本文标签: javascriptHow Facebook detects that you are awayStack Overflow