jQuery unload () method
Examples
When leaving the page, a message is displayed:
$(window).unload(function(){
alert("Goodbye!");
});
alert("Goodbye!");
});
try it"
Definition and Usage
unload () method in jQuery version 1.8 is discarded .
When the user leaves the page, unload event occurs.
When the following conditions occur, the unload event is triggered:
- Click on the link to leave a page
- In the address bar, type a new URL
- Use the Forward or Back button
- Close the browser window
- Reload the page
unload () method specifies what happens when unload when the event occurs.
unload () method applies only to the window object.
Note: unload event in different browsers is not the same effect, be sure to test before using this method in all browsers.
grammar
$(selector).unload(function)
参数 | 描述 |
---|---|
function | 必需。规定当触发 unload 事件时运行的函数。 |