Window: beforeprint event

The beforeprint event is fired when the associated document is about to be printed or previewed for printing.

Bubbles No
Cancelable No
Interface Event
Event handler property onbeforeprint

Examples

Using addEventListener():

window.addEventListener('beforeprint', (event) => {
  console.log('Before print');
});

Using the onbeforeprint event handler property:

window.onbeforeprint = (event) => {
  console.log('Before print');
};

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
beforeprint_event
63
12
6
Yes
50
13
63
63
?
46
13
8.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeprint_event