Seems to me that the best way to go around it would be just to warn the
users before they unload the page (whether closing it or moving to
another page) that they haven't submitted the form yet and that all the
data they inputted will get lost if they continue their action...

Regards,
-Yves-


> -----Original Message-----
> From: Andrew Hill [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 14, 2004 2:03 PM
> To: Struts Users Mailing List
> Subject: RE: submit form question
> 
> Yes, its a difficult one this.
> 
> (Afaik) Your only hope is onBeforeUnload(), but in most browsers I
have
> tried, getting the browser to submit the form at this point in time
simply
> didnt work properly for me (ie: it didnt submit!). Does submit() work
for
> you from inside a beforeUnload handler? If so your halfway there.
> 
> In my case I needed it to merely hit a url (to tell server side code
to
> clean out a particluar object from the session), so I achieved this by
> having it open a popup window (ouch!) that submits itself and closes.
In
> order to differentiate between a window navigation and a window close
I
> had
> to have all the navigation links work via javascript and have them set
a
> variable which the beforeUnload handler could check. If the variable
was
> not
> set it would assume it was a window close rather than a navigation and
go
> ahead and do its thing.
> 
> In your case things will be a lot more difficult as you have to get
the
> form
> data submitted to the server, and coming up with something that will
work
> cross-browser ... well good luck, but if I were you Id try and get
your
> requirements changed so you dont have to go into this particluar
> minefield!
> 
> Its been a while since I did that code so I cant remember all the
other
> options I looked at at the time, so maybe there is a better way to
achieve
> it?
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, 14 May 2004 13:44
> To: Struts Users Mailing List
> Subject: submit form question
> 
> 
> 
> Hi experts,
>         How to submit the form when the user closes the browser
window,
> before closing the browser window i want to submit the form.
> Which JavaScript event should i  use. i tried using onBeforeUnload(),
the
> problem is that this event gets fired even when the user goes to
> another page. Thanks in advance
> 
> Regards
> Subramaniam Olaganthan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to