Closed
Bug 1303295
Opened 10 years ago
Closed 10 years ago
The event "beforeunload" is not working after reloading page
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: ivan.otaman, Unassigned)
Details
(Whiteboard: [specification][type:bug])
What did you do?
================
1. I put this code on my site
window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "\o/";
e.returnValue = confirmationMessage; // Gecko, Trident, Chrome 34+
return confirmationMessage; // Gecko, WebKit, Chrome <34
});
2. I make sure that this code on the page
3. Then I set debuger breakpoint in the handler function
What happened?
==============
When I try to reload this page using browser reload button,
the breakpoint is working but after function ends I don't see any popup on my page.
What should have happened?
==========================
Popup with asking to leave the tab should be shown before page reloads.
Is there anything else we should know?
======================================
This code works correct when I click to F5 button on my keyboard. The same bug happens with browser's Back button. But after click to backspace button popup works correctly. The errors are absent.
| Reporter | ||
Updated•10 years ago
|
OS: Other → Windows 7
Hardware: All → x86
Updated•10 years ago
|
Component: Events → Untriaged
Product: Mozilla Developer Network → Firefox
| Reporter | ||
Comment 1•10 years ago
|
||
Sorry, I check this issue again, and found that steps what I already mentioned is wrong. The popup is shown only when I click to the window before unloading. But when I don't do anything before the unloading
| Reporter | ||
Comment 2•10 years ago
|
||
(In reply to ivan.otaman from comment #1)
> Sorry, I check this issue again, and found that steps what I already
> mentioned is wrong. The popup is shown only when I click to the window
> before unloading. But when I don't do anything before the unloading popup is not showing
| Reporter | ||
Updated•10 years ago
|
Summary: The event "documentation" is not working after reloading page → The event "beforeunload" is not working after reloading page
Comment 3•10 years ago
|
||
Thanks for the nice report, Ivan!
Marcos, is there maybe some spec ambiguity here or mis-interpretation?
Flags: needinfo?(mcaceres)
Comment 4•10 years ago
|
||
> Marcos, is there maybe some spec ambiguity here or mis-interpretation?
"unload" has always been problematic... will trying to reproduce relative to the HTML spec.
Flags: needinfo?(mcaceres)
Comment 5•10 years ago
|
||
Let's see what the spec says...
> The user agent is encouraged to avoid asking the user for confirmation if it judges that doing so would be annoying, deceptive, or pointless. A simple heuristic might be that if the user has not interacted with the document, the user agent would not ask for confirmation before unloading it.
So, technically, we this is working as expected... a reload doesn't count as the user interacting with the web application.
This can be proved by:
1. adding a textarea element to the document... and typing some stuff in it (hit reload)... give it a few seconds, hit reload.
2. waiting around ~30 seconds.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•