Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
63
12
6
13
63
13

The beforeprint event is fired when the associated document is about to be printed or previewed for printing.

63
12
6
13
63
13
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
window.addEventListener("afterprint", (event) => {
  console.log("After print");
});

Use cases

  • Using Print events

    The afterprint event is fired after the associated document has started printing or the print preview has been closed.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.