Detecting when a user leaves a page
From: Ben Paley (ben_at_spooty.net)
Date: 09/17/04
- Next message: Tendril: "Re: ignore_user_abort"
- Previous message: Janwillem Borleffs: "Re: ignore_user_abort"
- Next in thread: Donny: "Re: Detecting when a user leaves a page"
- Reply: Donny: "Re: Detecting when a user leaves a page"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 17 Sep 2004 21:35:51 GMT
Hello,
I need (I think) to find a way of detecting when a user leaves a web-page;
by hitting a link or the Back button, by typing into the address window, or
by closing the browser.
Here's why:
I'm writing a system to give a number of users access to documents (stored
in a mysql database) for shared editing. Most aspects of this have been
pretty easy, but I'm having trouble with the check-out part of it.
So far: when a user opens the edit page (doc_id sent in the query string)
the document is flagged as open in the database and subsequent attempts to
open it are refused. When the user hits Save, the document is updated and
the flag reset so the document can be opened. There's a time-out so that
after a couple of hours or the document is flagged as closed
irrespectively, on the assumption that they must have given up or got
bored.
The problem is that users may not hit the Save button! At the moment any
movement away from the page except via save means, effectively, that the
document is locked until the end of the time-out - even from the user who
opened it, so that, for instance, hitting Refresh is like letting your door
slam behind you when your key are inside...
This last, I can cure with a session variable holding the doc-id so that the
original user will retain access to the document even if they wander away
in the meantime - or maybe by putting the user's username into another
database column.
That's OK for /them/, but if they just leave the page or close their browser
without hitting Save, and without intending to come back, I can't think of
any way to detect this and reset the flag so that other users will again
have access to the document!
I'm tearing my hair out here: all suggestions very welcome.
Thanks in advance,
Ben
- Next message: Tendril: "Re: ignore_user_abort"
- Previous message: Janwillem Borleffs: "Re: ignore_user_abort"
- Next in thread: Donny: "Re: Detecting when a user leaves a page"
- Reply: Donny: "Re: Detecting when a user leaves a page"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|