Window: afterprint event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨September 2019⁩.

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

The @media print CSS at-rule, but it may be necessary to use these events in some cases.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("afterprint", (event) => { })

onafterprint = (event) => { }

Event type

A generic Event.

Examples

Using addEventListener():

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

Using the onafterprint event handler property:

js
window.onafterprint = (event) => {
  console.log("After print");
};

Specifications

Specification
HTML
# event-afterprint
HTML
# handler-window-onafterprint

Browser compatibility

See also

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant