WindowEventHandlers.onbeforeprint
The onbeforeprint property of the
WindowEventHandlers mixin is the event handler for
processing beforeprint events for the current window. These events are
raised before the print dialog window is opened.
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("beforeprint", function(event) { /* ... */ });
window.onbeforeprint = function(event) { /* ... */ };
Specifications
| Specification |
|---|
| HTML Standard # handler-window-onbeforeprint |
Browser compatibility
BCD tables only load in the browser