onpagehide event
Examples
Executed when the user from the web away from JavaScript:
Definition and Usage
onpagehide event is triggered when the user leaves the page.
There are many ways to leave the page. Such as clicking on a link, refresh the page, submit the form, close the browser and so on. .
onpagehide event is sometimes used instead onunload event, but can not be cached page after onunload event is triggered.
In order to view the page is loaded directly from the server or read from the cache, you can use the property PageTransitionEvent persisted objects to judge. If a page is read from the browser's cache, this property returns ture, otherwise return false.
Browser Support
Figures in the table represent the first browser to support this version of events.
event | |||||
---|---|---|---|---|---|
onpagehide | Yes | 11.0 | Yes | 5.0 | Yes |
grammar
In HTML:
In JavaScript:
JavaScript, use the addEventListener () method:
Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.
technical details
Whether to support the bubble: | No |
---|---|
It can be canceled: | No |
Event Type: | PageTransitionEvent |
Supported HTML tags: | <Body> |
Event objects