New issue
Advanced search Search tips

Issue 616630 link

Starred by 4 users

Issue metadata

Status: Duplicate
Merged: issue 587940
Owner: ----
Closed: Jun 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

onbeforeunload handler no longer allows custom confirm message

Reported by xander.d...@gmail.com, Jun 1 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36

Steps to reproduce the problem:
1. Create a window.onbeforeunload handler that returns a confirm('custom message')
2. reload the page
3. 

https://jsfiddle.net/4fk04k2z/

What is the expected behavior?
The custom message is shown in the prompt

What went wrong?
The custom message was not shown in the prompt.

Did this work before? N/A 

Chrome version: 51.0.2704.63  Channel: stable
OS Version: OS X 10.11.4
Flash Version: Shockwave Flash 21.0 r0

It's important to be able to show a custom message in this prompt, because the stock message does not apply to all scenarios "Changes you made may not be saved." doesn't make any sense if there are no changes and nothing to save. For example, we're using this is a webrtc phone application that shows the prompt to prevent disconnecting the call by accidentally reloading or closing the tab.
 
Well I may have had a brain hiccup there - `onbeforeunload` should return a string, not  a confirm. But it doesn't actually work either - https://jsfiddle.net/4fk04k2z/3/
If the new behavior is such that this is no longer available to customize, then I'd request that the message be changed if there are active RTCPeerConnections, to something like, "Your connection will be ended" Suggest label `webrtc` for this bug.
Components: -UI Blink>JavaScript>API
Labels: Needs-Feedback
The custom message appears when I click the Reload button in the link in #1.

I am also having this problem. The text provided is never used.
It was working previously.

The w3schools page doesn't work either.
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onbeforeunload

Chrome Version 51.0.2704.79 m
https://www.chromestatus.com/features/5349061406228480

it says here that "custom messages in onbeforeunload dialogs" was removed in chrome 51


> It's important to be able to show a custom message in this prompt, because the stock message does not apply to all scenarios "Changes you made may not be saved." doesn't make any sense if there are no changes and nothing to save.

i agree

i noticed google play music shows that message when you try to close the tab while music is playing
For almost any rich real-time application not being able to describe to the user why we are trying to prevent them from accidentally doing something they might not wan't to do is imperative.

In my case there are several different cases where the default prompt is not good enough.

Just some of our features that require this behavior:
 - Document changes
 - Chat
 - Video conference (webrtc)
 - Audio
 - Presentations
 - File transfer / upload
 - Queries in progress / long running task
 - Availability to other peers

For the sake of being able to deliver richer experiences in a browser into the future we need to be able to have this kind of function somehow.

I'm not convinced yet that "Changes you made may not be saved" is sufficient to describe the loss scenario in these cases and -will- be overlooked by users and the loss will be more frustrating than any result of abuse of the prompt.
Components: -Blink>JavaScript>API Blink
This has nothing to do with V8.
Cc: a...@chromium.org
Components: -Blink Blink>WindowDialog

Comment 9 by a...@chromium.org, Jun 6 2016

Mergedinto: 587940
Status: Duplicate (was: Unconfirmed)
This is intentional, as noted in comment 5.

Sign in to add a comment