From 3f0ff893000c8927f194612371da3fcab4c21c6d Mon Sep 17 00:00:00 2001 From: Arthur Verschaeve Date: Wed, 28 Jan 2015 16:52:15 +0100 Subject: [PATCH 1/2] Unload: update outdated example --- entries/unload.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entries/unload.xml b/entries/unload.xml index e7c12492..aae1cefd 100644 --- a/entries/unload.xml +++ b/entries/unload.xml @@ -28,7 +28,7 @@

Any unload event handler should be bound to the window object:


 $( window ).unload(function() {
-  alert( "Handler for .unload() called." );
+  return "Handler for .unload() called.";
 });
     

After this code executes, the alert will be displayed whenever the browser leaves the current page. @@ -39,7 +39,7 @@ It is not possible to cancel the unload event with .preventDe To display an alert when a page is unloaded: From b44ca0ad32ba2a8f9518a3b3e693207b6e3d5752 Mon Sep 17 00:00:00 2001 From: Arthur Verschaeve Date: Sat, 31 Jan 2015 11:24:15 +0100 Subject: [PATCH 2/2] Fixes for PR --- entries/unload.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/entries/unload.xml b/entries/unload.xml index aae1cefd..e33dc639 100644 --- a/entries/unload.xml +++ b/entries/unload.xml @@ -31,9 +31,7 @@ $( window ).unload(function() { return "Handler for .unload() called."; }); -

After this code executes, the alert will be displayed whenever the browser leaves the current page. -It is not possible to cancel the unload event with .preventDefault(). This event is available so that scripts can perform cleanup when the user leaves the page. -

+

This event is available so that scripts can perform cleanup when the user leaves the page. Most browsers will ignore calls to alert(), confirm() and prompt() 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 unload event with .preventDefault().

To display an alert when a page is unloaded: