The WindowEventHandlers.onafterprint property sets and returns the onafterprint EventHandler for the current window.
window.onafterprint = event handling code
Some browsers (including Firefox 6 and later and Internet Explorer) send beforeprint and afterprint events to let content determine when printing may have occurred. You can use this to adjust the user interface presented during printing (such as by displaying or hiding user interface elements during the print process).
The afterprint event is raised after the user prints or aborts a print dialog.
Not part of any specification.
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | No support | (Yes) | 6.0 | (Yes) | No support | No support |
| Feature | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| ? | ? | (Yes) | ? | ? | ? | ? |
window.printwindow.onbeforeprintmatchMedia('print')
var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (!mql.matches) {
console.log('onafterprint');
};
});
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint