HTML onpageswap Event Attribute
Description
The onpageswap event attribute is used on the <body> element (or as window.onpageswap) and runs a script when a document is about to be unloaded because of a navigation to another document, just before the last frame of the old page is captured.
It is mainly used with cross-document view transitions: event.viewTransition holds the outgoing ViewTransition (or null), and event.activation describes the navigation, including the destination entry, so the old page can set view-transition-name on the element that should animate. Its counterpart on the new page is onpagereveal.
Syntax
<body onpageswap="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 onpageswap event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.
Desktop





Tablets & Mobile





