Easy Tutorial
❮ Tag S Tag Optgroup ❯

HTML5 onbeforeprint Event Attribute

HTML Event Attributes

Example

Set up the page for printing, but execute JavaScript before the print dialog appears:


Browser Support

Event
onbeforeprint 63 Yes Yes 13 50

Definition and Usage

The onbeforeprint attribute is triggered when the user sets the page to print, but before the print dialog appears.

Tip: The onbeforeprint attribute is often used together with the onafterprint attribute.


Differences Between HTML4.01 and HTML5

The onbeforeprint attribute is a new attribute in HTML5.


Syntax

Attribute Values

Value Description
script The script to be executed in onafterprint.

❮ Tag S Tag Optgroup ❯