Events

onpagereveal

A document is first rendered after navigation or activation, including some cached or prerendered cases. Window event handler, exposed through the body element in HTML; register on window rather than on an arbitrary element. Event interface: PageRevealEvent. For the described native event: bubbles: no; cancelable: no. viewTransition may be null. Register early, before rendering; newer cross-document transition support varies. Example: Run this as a standalone page; the browser must generate the relevant lifecycle event. The event listener is registered with addEventListener(), which avoids inline script handlers and supports multiple listeners. Inline handlers require a CSP that permits them; do not insert untrusted code into handler attributes.

Formal Syntax & Structure

html syntaxhtml
<body onpagereveal="handleEvent(event)">  window.addEventListener("pagereveal", event => { /* handle event */ });

Parameters & Attributes

NameTypeDescription
onpagerevealJavaScript handler bodyOptional HTML event-handler code; the example uses a registered listener instead. Not a Boolean attribute.
eventPageRevealEventEvent object delivered to the addEventListener callback; event.type is "pagereveal". Inspect target, currentTarget, bubbles and cancelable as appropriate.

Working Example

Example Snippethtml
<p>Window event monitor</p><p role="status" id="log">Waiting for pagereveal</p><script>  const target = window;  const log = document.getElementById("log");  target.addEventListener("pagereveal", event => {    log.textContent = String(event.type);  });</script>
HTML Reference