PageTransitionEvent
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The PageTransitionEvent
event object is available inside handler functions for the pageshow
and pagehide
events, fired when a document is being loaded or unloaded.
Constructor
PageTransitionEvent()
-
Creates a new
PageTransitionEvent
object.
Instance properties
This interface also inherits properties from its parent, Event
.
PageTransitionEvent.persisted
Read only-
Indicates if the document is loading from a cache.
Example
HTML
html
<!doctype html>
<html lang="en-US">
<body></body>
</html>
JavaScript
js
window.addEventListener("pageshow", (event) => {
if (event.persisted) {
alert("The page was cached by the browser");
} else {
alert("The page was NOT cached by the browser");
}
});
Specifications
Specification |
---|
HTML # the-pagetransitionevent-interface |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
PageTransitionEvent | ||||||||||||
PageTransitionEvent() constructor | ||||||||||||
persisted |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.