Thursday, March 31, 2011

Re: How to know if a user has left a particular page

On Thu, Mar 31, 2011 at 5:15 PM, euromark <dereuromark@googlemail.com> wrote:
> "The exact handling of the unload event has varied from version to
> version of browsers. For example, some versions of Firefox trigger the
> event when a link is followed, but not when the window is closed. In
> practical usage, behavior should be tested on all supported browsers,
> and contrasted with the proprietary beforeunload event."
> source: http://api.jquery.com/unload/
>
> so it seems this is not an exact science

Yes, onUnload has never been reliable. Pinging with AJAX is the more
suitable approach anyway. The problem should not be formulated as
learning the exact moment when the user left the page but instead
testing whether the user was there recently. Set some value for the
period of time between pings. If, at the time you check, the ping
timestamp is older than that value, pause for some time, then check
again. If the timestamp hasn't changed, user can be considered gone.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: