Web/API/PageTransitionEvent

From Get docs

The PageTransitionEvent event object is available inside handler functions for the pageshow and pagehide events, fired when a document is being loaded or unloaded.

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

<!DOCTYPE html>
<html>
<body>
</body>
</html>

JavaScript

window.addEventListener('pageshow', myFunction);

function myFunction(event) { 
  if (event.persisted) {
    alert("The page was cached by the browser");
  } else {
    alert("The page was NOT cached by the browser");
  }
}

Specifications

Specification Status Comment
HTML Living StandardThe definition of 'PageTransitionEvent' in that specification. Living Standard Initial definition

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PageTransitionEvent Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support Yes

IE

Full support Yes

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support Yes

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

persisted Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support Yes

IE Full support 11

Notes'

Full support 11

Notes'

Notes' The persisted property is known to be buggy in Internet Explorer. It is advised to check if window.performance.navigation.type == 2 as well.

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support Yes

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support
See implementation notes.'
See implementation notes.


See also