onafterprint Event

Definition and Usage

The onafterprint event occurs when the page has started printing, or if the print dialog has been closed.

Tip: The onafterprint event is related to onbeforeprint EventConversely.

Example

Execute JavaScript when the page starts printing:

<body onafterprint="myFunction()">

Try it yourself

Syntax

In HTML:

<element onafterprint="myScript">

Try it yourself

In JavaScript:

object.onafterprint = function(){myScript};

Try it yourself

In JavaScript, use the addEventListener() method:

object.addEventListener("afterprint", myScript);

Try it yourself

Note:Internet Explorer 8 or earlier versions do not support addEventListener() Method.

Technical Details

Bubble: Not Supported
Cancellable: Not Supported
Event Type: Event
Supported HTML Tags: <body>
DOM Version: Level 3 Events

Browser Support

Events Chrome IE Firefox Safari Opera
onafterprint 63 Supported Supported Not Supported Not Supported