Skip to content

Commit

Permalink
Ignore beforeunload event return value
Browse files Browse the repository at this point in the history
Instead of using it as the message to show to the user, simply compare
it against the empty string or not. This matches Gecko, WebKit, and
Blink (but not yet EdgeHTML).

Closes #952.
  • Loading branch information
domenic committed Apr 5, 2016
1 parent a996f3b commit 4163263
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -35736,7 +35736,7 @@ sfx.oncanplaythrough = function () {
// meow when the user tries to leave
window.onbeforeunload = function () {
playSound('kitten mew');
return 'Are you sure you want to leave this awesome page?';
return true;
}</pre>

</div>
Expand Down Expand Up @@ -82198,9 +82198,9 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {
object is not the empty string, or if the event was canceled, then the user agent should ask the
user to confirm that they wish to unload the document.</p>

<p>The prompt shown by the user agent may include the string of the <code
data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code> attribute, <span
data-x="optionally truncate a simple dialog string">optionally truncated</span>.</p>
<p class="note">The message shown to the user is not customizable, but instead determined by
the user agent. In particular, the actual value of the <code
data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code> attribute is ignored.</p>

<p>The user agent must <span>pause</span> while waiting for the user's response.</p>

Expand Down Expand Up @@ -82377,13 +82377,14 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {

<dl class="domintro">

<dt><var>event</var> . <code subdfn data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code> [ = <var>value</var> ]</dt>
<dt><var>event</var> . <code subdfn data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code> [ = " " ]</dt>

<dd>

<p>Returns the current return value of the event (the message to show the user).</p>

<p>Can be set, to update the message.</p>
<p>Can be set, to request that the user agent to confirm with the user their intention to
unload the document. Any value besides the empty string will suffice for this purpose.</p>

</dd>

Expand All @@ -82394,10 +82395,15 @@ dictionary <dfn>PageTransitionEventInit</dfn> : <span>EventInit</span> {
<div w-nodev>

<p>The <dfn><code data-x="dom-BeforeUnloadEvent-returnValue">returnValue</code></dfn> attribute
represents the message to show the user. When the event is created, the attribute must be set to
controls the process of <span data-x="prompt to unload a document">prompting to unload the
document</span>. When the event is created, the attribute must be set to
the empty string. On getting, it must return the last value it was set to. On setting, the
attribute must be set to the new value.</p>

<p class="note">This attribute is a <code data-x="">DOMString</code> only for historical reasons.
Any value besides the empty string will be treated as a request to ask the user for
confirmation.</p>

</div>


Expand Down Expand Up @@ -86996,7 +87002,7 @@ typedef <span>EventHandlerNonNull</span>? <dfn>EventHandler</dfn>;</pre>
<span w-nodev>as described above,</span> if the return value is false, the event is canceled
(except for <code data-x="event-mouseover">mouseover</code> events, where the return value has to
be true to cancel the event). With <code data-x="event-beforeunload">beforeunload</code> events,
the value is instead used to determine the message to show the user.</p>
the value is instead used to determine whether or not to prompt about unloading the document.</p>

<p>For historical reasons, the <code data-x="handler-onerror">onerror</code> handler has different
arguments:</p>
Expand Down

0 comments on commit 4163263

Please sign in to comment.