Favorites

HTML onpagereveal Event Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
onpagereveal
HTML Event AttributeThis event attribute is supported in some modern browsers, but not all.
Updated 22nd November 2026

Description

The onpagereveal event attribute is used on the <body> element (or as window.onpagereveal) and runs a script when a document is about to be rendered for the first time: after a normal navigation, after the page is restored from the back/forward cache, or when a prerendered page is activated.

It is mainly used with cross-document view transitions. The event's viewTransition property holds the active ViewTransition object, or null if there is none, so the page can customise or skip the incoming transition based on where the user came from. Its counterpart on the old page is onpageswap.

window.addEventListener("pagereveal", (event) => {
  if (event.viewTransition && navigation.activation.navigationType === "traverse") {
    event.viewTransition.types.add("back");
  }
});

Syntax

<body onpagereveal="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
<title>onpagereveal event</title>
</head>
<body>
<p id="info">Waiting for pagereveal...</p>
<script>
window.onpagereveal = function (event) {
document.getElementById("info").textContent = "pagereveal fired. View transition: " + (event.viewTransition ? "yes" : "none");
};
</script>
</body>
</html>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML onpagereveal event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.

This event attribute is supported in some modern browsers, but not all.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee