Detecting when a user leaves a page

From: Ben Paley (ben_at_spooty.net)
Date: 09/17/04


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



Relevant Pages

  • Re: validation rule
    ... "Marshall Barton" wrote: ... I can't go to database view, ... Try hitting the Excape key twice to undo all changes to the ...
    (microsoft.public.access.formscoding)
  • Cant retrieve any schema info in UDB
    ... I am hitting an AIX UDB 7 Database, and the problem I am having is that I am ... Mainframe DB2 database and it was working. ... I am trying to run these commands to retrieve the primary keys. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Photo Gallery with next and previous buttons
    ... > Dynamically from database, we are getting set of images names. ... > server. ... > Is it possible to acheive that without hitting the database. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Opening large excel files
    ... this sounds like you're hitting Excel's limit. ... database). ... > trouble opening an Excel file which is currently 114Mb's ... > setup. ...
    (microsoft.public.excel.misc)
  • Re: Update Application value on multiple servers?
    ... > hitting a database is going to add noticeable response time to the page, ... Ray at home ...
    (microsoft.public.inetserver.asp.general)