Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML onafterprint Event Attribute

❮ HTML Event Attributes

Example

Execute a JavaScript when a page has started printing, or if the print dialogue box has been closed:

<body onafterprint="myFunction()">
Try it Yourself »

Definition and Usage

The onafterprint attribute fires when a page has started printing, or if the print dialogue box has been closed.

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


Browser Support

Event Attribute
onafterprint 63 Yes Yes Not supported Not supported

Note: In IE/Edge, the onafterprint attribute occurs before the print dialogue box, instead of after.


Syntax

<element onafterprint="script">

Attribute Values

Value Description
script The script to be run on onafterprint

Technical Details

Supported HTML tags: <body>

Related Pages

HTML DOM reference: onafterprint event


❮ HTML Event Attributes