``` --- ## Definition and Usage "> ``` --- ## Definition and Usage " />
Easy Tutorial
❮ Prop Frameset Rows Prop Video Controls ❯

onbeforeprint Event

Event Object

Example

Execute JavaScript when the page is about to be printed:

<body onbeforeprint="myFunction()">

Definition and Usage

The onbeforeprint event is triggered when the page is about to be printed (before the print dialog appears).

Tip: The opposite event of onbeforeprint is onafterprint.


Browser Support

Event
onbeforeprint Not supported Yes Yes Not supported Not supported

Syntax

In HTML:

In JavaScript:

In JavaScript, using the addEventListener() method:

Note: Internet Explorer 8 and earlier versions do not support the addEventListener() method.


Bubbles: No
Cancelable: No
--- ---
Event Type: Event
--- ---
Supported HTML Tags: <body>
--- ---
❮ Prop Frameset Rows Prop Video Controls ❯