Closed
Bug 652069
Opened 13 years ago
Closed 10 years ago
Sometimes data of form can't be sent in onbeforeunload event handler
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 560767
People
(Reporter: promo.ivan21, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0 Build Identifier: Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0 Create handler on onbeforeunload event. This handler calls submit function of form at the end handler. Sometimes the form's data can't be sent. It works correctly in FF 3.6, Google Chrome, IE Reproducible: Sometimes Steps to Reproduce: 1. In body tag to add onbeforeunload event handler 2. In the event handler to fill form then call submit function of this form Actual Results: Sometimes data is not sent. Expected Results: Always data should be sended My the event handler looks like: function onUnload() { var sessionId = document.getElementById('${application}').getSessionId(); var globalConnectionName = document.getElementById('${application}').getConnectionName(); if (sessionId == null) return; logoutForm.session.value = sessionId; logoutForm.connection_name.value = globalConnectionName; logoutForm.time.value = new Date().getTime(); logoutForm.submit(); }
Summary: Sometimes form's data can't be sent in onbeforeunload event handler → Sometimes data of form can't be sent in onbeforeunload event handler
![]() |
||
Updated•13 years ago
|
Version: unspecified → 4.0 Branch
I have the same problem. I let the user choose saving the data in this event but fail. With Firebug help, found out the form is not submitted totally. This happens in FF4.0.1 on XP/Linux. My code works in IE8 and FF3.6.17.
missed one thing: after submit a form, if alert any message, like "data are sent to save", the form can be submitted and data are saved. seems FF4 goes right away after executing submit() function. At first, I thought maybe it is too fast after submit() func to make it fails to send out the form. So I tried to delay 2-5 seconds (setTimeout("1=1;", 2/5000)) after submit() function ,simulating alert affect, but failed. Thus it is a time problem. Maybe it is bubble problem: FF executes submit() function but fails to catch it?!
now I use ajax to save the data. Don't forget to set its async property with false. If Async=true, it doesn't work, too. Hope this can help someone.
Comment 4•10 years ago
|
||
I think this is expected behaviour, at least in the way that you should not depend on onbeforeunload to execute reliably, especially for outgoing connections. I'd rather try to store data on beforeunload in localStorage, or better, periodically (or input[onchange]) before any unload happens. So I'd WONTFIX this bug though iirc this is only something peers should do/decide.
Comment 5•10 years ago
|
||
Actually, I'm just going to duplicate this to Bug 560767 which aims to block any navigation/redirection in onbeforeunload (which this bug should fall into).
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•