The WindowEventHandlers.onafterprint property sets and returns the afterprint EventHandler for the current window.


window.onafterprint = event handling code


The beforeprint and afterprint events allow pages to change their content before printing starts (perhaps to remove a banner, for example) and then revert those changes after printing has completed. In general content authors should prefer the use of an @media print CSS at-rule, but it may be necessary to use these events in some cases.

The afterprint event is raised after the user prints, or if they abort the print dialog.

Safari does not implement these events.


Browser compatibilityUpdate compatibility data on GitHub

Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 63 Yes 6 Yes 50 No
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 63 63 Yes ? 50 ? ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.