Skip to content

Commit e82e9db

Browse files
committed
Unload: update examples using alert()
Fixes gh-388 Closes gh-639
1 parent 996e73b commit e82e9db

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

entries/unload.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,16 @@
2828
<p>Any <code>unload</code> event handler should be bound to the <code>window</code> object:</p>
2929
<pre><code>
3030
$( window ).unload(function() {
31-
alert( "Handler for .unload() called." );
31+
return "Handler for .unload() called.";
3232
});
3333
</code></pre>
34-
<p>After this code executes, the alert will be displayed whenever the browser leaves the current page.
35-
It is not possible to cancel the <code>unload</code> event with <code>.preventDefault()</code>. This event is available so that scripts can perform cleanup when the user leaves the page.
36-
</p>
34+
<p>This event is available so that scripts can perform cleanup when the user leaves the page. Most browsers will ignore calls to <code>alert()</code>, <code>confirm()</code> and <code>prompt()</code> inside the event handler. The string you return may be used in a confirmation dialog, but not all browsers support this. It is not possible to cancel the <code>unload</code> event with <code>.preventDefault()</code>.</p>
3735
</longdesc>
3836
<example>
3937
<desc>To display an alert when a page is unloaded:</desc>
4038
<code><![CDATA[
4139
$( window ).unload(function() {
42-
alert( "Bye now!" );
40+
return "Bye now!";
4341
});
4442
]]></code>
4543
</example>

0 commit comments

Comments
 (0)