what happens if I submit a form in the onunload event?

J

jackchang1

I have an application that will submit the form when the page is closed
(through onunload event), and it works fine in IE6. But it doesn't work
in FireFox, and no data is sent. It seems to me that FireFox doesn't
let the onunload event ends before the window is closed. Or is it an
form submit issue in the onunload event?

Thanks!
 
B

Benjamin

I have an application that will submit the form when the page is closed
(through onunload event), and it works fine in IE6. Really?

But it doesn't work
in FireFox, and no data is sent. It seems to me that FireFox doesn't
let the onunload event ends before the window is closed. Or is it an
form submit issue in the onunload event?
When you submit a form with the unload handler, you are sending the
browser to a different page. It's a bad idea!
 
J

jackchang1

"Benjamin дµÀ£º
"
When you submit a form with the unload handler, you are sending the
browser to a different page. It's a bad idea!
Are there any better solutions to this problem? I need to submit the
data when the user close the window. The only thing I can think about
is to provide a button on my page and clicking that button will submit
the data and close the window. But users can still click 'x' to close
the window and data is lost.
 
V

VK

Are there any better solutions to this problem? I need to submit the
data when the user close the window. The only thing I can think about
is to provide a button on my page and clicking that button will submit
the data and close the window. But users can still click 'x' to close
the window and data is lost.

<http://groups.google.com/group/comp.lang.javascript/msg/a0c582dc42c65fd2>

I would suggests (humbly) to skip on onunload part and use the
sessionID way
 
B

Benjamin

"Benjamin дµÀ£º
"
Are there any better solutions to this problem? I need to submit the
data when the user close the window. The only thing I can think about
is to provide a button on my page and clicking that button will submit
the data and close the window. But users can still click 'x' to close
the window and data is lost.
Of the other ideas mentioned (sessions and AJAX), sessions are the most
reliable. Of course these have to be done on the server-side. AJAX is
only supported on the latest browsers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top