Definition and Usage
The onpagehide event occurs when the user is navigating away from a webpage.
There are several ways to navigate away from a page. E.g. by clicking on a link, refreshing the page, submitting a form, closing the browser window, etc.
The onpagehide event is sometimes used instead of the onunload event, as the onunload event causes the page to not be cached.
To find out if a page is loaded directly from the server or if the page is cached, you can use the persisted property of the PageTransitionEvent object. This property returns true if the page is cached by the browser, and false otherwise.
The numbers in the table specify the first browser version that fully supports the event.
Note: Due to different browser settings, this event may not always work as expected.
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
|Supported HTML tags:||<body>|
|DOM Version:||Level 3 Events|
❮ Event Object