PageTransitionEvent

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

Event PageTransitionEvent

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
HTML Standard
# the-pagetransitionevent-interface

Browser compatibility

BCD tables only load in the browser

See also