Execute a JavaScript when a page is about to be printed:
The onbeforeprint attribute fires when a page is about to be printed (before the print dialogue box appears).
Tip: The onbeforeprint attribute is often used together with the onafterprint attribute.
Event Attribute | |||||
---|---|---|---|---|---|
onbeforeprint | Not supported | Yes | Yes | Not supported | Not supported |
The onbeforeprint attribute is new in HTML5.
Value | Description |
---|---|
script | The script to be run on onbeforeprint |
Supported HTML tags: | <body> |
---|
HTML DOM reference: onbeforeprint event