You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!
The onafterprint
property of the WindowEventHandlers
mixin is the EventHandler
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 an @media print
CSS at-rule, but it may be necessary to use these events in some cases.
Syntax
window.addEventListener("afterprint", function(event) { ... }); window.onafterprint = function(event) { ... };
Specification
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'onafterprint' in that specification. |
Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
onafterprint | Chrome Full support 63 | Edge Full support Yes | Firefox Full support 6 | IE Full support Yes | Opera Full support 50 | Safari No support No | WebView Android Full support 63 | Chrome Android Full support 63 | Firefox Android ? | Opera Android Full support 46 | Safari iOS ? | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown