The PageTransitionEvent
event object is available inside handler functions for the pageshow
and pagehide
events, fired when a document is being loaded or unloaded.
On this page
PageTransitionEvent
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 Standard # the-pagetransitionevent-interface |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
PageTransitionEvent |
16 | 79 | 11 | No | 15 | 6 | 4.4 | 18 | 14 | 14 | 6 | 1.0 |
PageTransitionEvent |
4 | 12 | 1.5 | 11 | 15 | 5 | ≤37 | 18 | 4 | 14 | 4 | 1.0 |
persisted |
4 | 12 | 11 |
11Thepersisted property is known to be buggy in Internet Explorer. It is advised to check if window.performance.navigation.type == 2 as well.
|
15 | 5 | ≤37 | 18 | 14 | 14 | 4 | 1.0 |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PageTransitionEvent