onafterprint Event
Example
Execute a JavaScript when a page has started printing:
<body onafterprint="myFunction()">
Try it yourself »
Definition and Usage
The onafterprint event occurs when a page has started printing, or if the print dialogue box has been closed.
Tip: The onafterprint event is the opposite of the onbeforeprint event.
Browser Support
Event | |||||
---|---|---|---|---|---|
onafterprint | Not supported | Yes | Yes | Not supported | Not supported |
Syntax
In HTML:
<element onafterprint="myScript">Try it
In JavaScript:
object.onafterprint=function(){myScript};Try it
In JavaScript, using the addEventListener() method:
object.addEventListener("afterprint", myScript);Try it
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Technical Details
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <body> |
DOM Version: | Level 3 Events |
Event Object