HTML5 onafterprintEvent Attribute

HTML 事件属性HTML Event Attributes

Example

Execute JavaScript after the page is set to print and the print dialog appears:

<body onafterprint="printmsg()">

Try it yourself »

Browser Support

Event Attribute
onafterprint 63 12 6 13 50

Note:In IE browsers, the onafterprint attribute executes JavaScript before the print dialog appears, rather than after.


Definition and Usage

The onafterprint attribute triggers after the user sets the page to print and the print dialog appears.

Tip:The onafterprint attribute is usually used with theonbeforeprintattribute together.


Difference between HTML 4.01 and HTML5

The onafterprint attribute is a new HTML5 attribute.


Syntax

<element onafterprint="script">

Attribute Value

Value Description
script The script to be executed in onafterprint.


HTML 事件属性HTML Event Attributes Other Extensions