I looked up beforeunload, but I ruled it out because it's currently
only supported in IE and FireFox/Mozilla, and the latter implements
different behaviour for it than IE does.  Opera and Safari don't
support it at all.  The script has to be cross-browser.

On May 30, 4:43 pm, Stuart <[EMAIL PROTECTED]> wrote:
> What you want to do is bind a function to the onbeforeunload event of
> the window object (ie. window.onbeforeunload = someFunction;). The
> onbeforeunload event fires before onunload as the name implies. Here's
> a couple artices that should get you on 
> track:http://www.boutell.com/newfaq/creating/disableclose.htmlandhttp://www.4guysfromrolla.com/webtech/100604-1.shtml,
>  just remember
> that you can't prevent a user from unloading a page, you can only
> throw up a confirm dialog and use the "hook" to do your final
> processing.
>
> On May 30, 10:26 am, "Brian Miller" <[EMAIL PROTECTED]> wrote:
>
> > Web browsers simply don't do this well.  It breaks the whole
> > non-persistent model.  No matter what you do, you'll have to deal with
> > network latency.  Also, Browsers react differently when the user closes
> > the browser window.  I don't think that the onunload event is reliable for
> > all the use cases.
>
> > Having a 15-second "autosave" is going to be your best fallback.  I only
> > hope that your management is going to be flexible on this.  Unfortunately,
> > what they want is outside the scope of what browsers can generally
> > provide.
>
> > - Brian
>
> > > Not strictly speaking a jQuery question but I thought somebody on here
> > > might have some insight into this. :)
>
> > > The Powers That Be have asked me for a system whereby the contents of
> > > a form is automatically saved to the server whenever the user leaves
> > > the page.  I looked into onunload but from what I can asertain by the
> > > time that event fires the form already no longer exists and can't be
> > > submitted to the server.  Doing an AJAX post whenever the form changes
> > > isn't acceptible because that would generate too much database
> > > traffic, so I'm kind of stuck.  I did suggest preservign the data in a
> > > cookie instead of the database but that is apparently not acceptable
> > > either.
>
> > > Is there some other way I could have the form submitted when the user
> > > leaves the page?

Reply via email to