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
<body onpagereveal="handleEvent(event)"> window.addEventListener("pagereveal", event => { /* handle event */ });Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| onpagereveal | JavaScript handler body | Optional HTML event-handler code; the example uses a registered listener instead. Not a Boolean attribute. |
| event | PageRevealEvent | Event object delivered to the addEventListener callback; event.type is "pagereveal". Inspect target, currentTarget, bubbles and cancelable as appropriate. |
Working Example
<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>