HTML onpagereveal Event Attribute
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
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.
Desktop





Tablets & Mobile





