The onafterprint property of the WindowEventHandlers mixin is the event handler for processing afterprint events for the current window. These events are raised after the user prints, or if they abort the print dialog.

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, you should prefer the use of a @media print CSS at-rule, but it may be necessary to use these events in some cases.


window.addEventListener("afterprint", function(event) { /* ... */ });
window.onafterprint = function(event) { /* ... */ };


HTML Standard (HTML)
# handler-window-onafterprint

Browser compatibility

BCD tables only load in the browser

See also