ExampleAlert a message when the user navigates away from the page:
Try it yourself » |
The unload event occurs when the user navigates away from the page.
The unload event is triggered when:
The unload() method specifies what happens when a unload event occurs.
The unload() method should only be used on the window object.
$(selector).unload(function) |
Parameter | Description |
---|---|
function | Required. Specifies the function to run when the unload event is triggered. |