HTML onbeforeprint event eigenschap
Example
Execute JavaScript after setting the page to print but before the print dialog box appears:
<body onbeforeprint="printmsg()">
Browser support
IE | Firefox | Chrome | Safari | Opera |
---|---|---|---|---|
Only Internet Explorer and Firefox support the onafterprint event attribute.
Definition and usage
The onbeforeprint attribute triggers immediately after the user has set the page to print, but before the print dialog box appears.
Tip:The onbeforeprint attribute is often used with the onafterprint attribute.
Differences between HTML 4.01 and HTML5
The onbeforeprint attribute is a new attribute in HTML5.
Syntax
<element onbeforeprint="script">
Attribute value
Value | Description |
---|---|
script | Script runs when onbeforeprint occurs. |