diff --git a/source b/source index 1e90b7b96f4..f114cfd9de7 100644 --- a/source +++ b/source @@ -3104,7 +3104,7 @@ a.setAttribute('href', 'http://example.com/'); // change the content attribute d
  • appendChild() method
  • cloneNode() method
  • importNode() method
  • - +
  • preventDefault() method
  • id attribute
  • textContent attribute
  • @@ -35734,10 +35734,11 @@ function playSound(id) { sfx.oncanplaythrough = function () { playSound('dog bark'); } -// meow when the user tries to leave -window.onbeforeunload = function () { +// meow when the user tries to leave, +// and have the browser ask them to stay +window.onbeforeunload = function (e) { playSound('kitten mew'); - return 'Are you sure you want to leave this awesome page?'; + e.preventDefault(); } @@ -82214,9 +82215,9 @@ dictionary PageTransitionEventInit : EventInit { 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.

    -

    The prompt shown by the user agent may include the string of the returnValue attribute, optionally truncated.

    +

    The message shown to the user is not customizable, but instead determined by + the user agent. In particular, the actual value of the returnValue attribute is ignored.

    The user agent must pause while waiting for the user's response.

    @@ -82391,29 +82392,28 @@ dictionary PageTransitionEventInit : EventInit { attribute DOMString returnValue; }; -
    - -
    event . returnValue [ = value ]
    - -
    - -

    Returns the current return value of the event (the message to show the user).

    - -

    Can be set, to update the message.

    - -
    - -
    -

    There are no BeforeUnloadEvent-specific initialisation methods.

    +

    The BeforeUnloadEvent interface is a legacy interface which allows prompting to unload the document to be controlled + not only by canceling the event, but by setting the returnValue attribute to a value besides the + empty string. Authors should use the preventDefault() method, or other means of canceling + events, instead of using returnValue.

    +

    The returnValue attribute - represents the message to show the user. When the event is created, the attribute must be set to + controls the process of prompting to unload the + document. 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.

    +

    This attribute is a DOMString only for historical reasons. + Any value besides the empty string will be treated as a request to ask the user for + confirmation.

    +
    @@ -87031,7 +87031,7 @@ typedef EventHandlerNonNull? EventHandler; as described above, if the return value is false, the event is canceled (except for mouseover events, where the return value has to be true to cancel the event). With beforeunload events, - the value is instead used to determine the message to show the user.

    + the value is instead used to determine whether or not to prompt about unloading the document.

    For historical reasons, the onerror handler has different arguments: