Try printing this web page (e.g. with CTRL+P).
--- ### Related Events | Event | Description | | :--- | :--- | | (#) | Occurs when the user starts to print a document | | (#) | Occurs when there has been a change to the anchor part of the URL | | (#) | Occurs when a message is received through an event source | | (#) | Occurs when the browser starts to work offline | | (#) | Occurs when the browser starts to work online | | (#) | Occurs when the user navigates away from a webpage | | (#) | Occurs when the user navigates to a webpage | | (#) | Occurs when the user navigates back in the history | | (#) | Occurs when the browser window is resized | | (#) | Occurs when a Web Storage area is updated | | (#) | Occurs once a page has unloaded (or the browser window has been closed) |Ev Onafterprint
## HTML5 onafterprint Event Attribute
The `onafterprint` event occurs after the user has finished printing or if the print dialog has been cancelled.
This event is part of the (#) object.
**Note:** The `onafterprint` event is the opposite of the (#) event.
**Note:** This event is not supported in Internet Explorer 8 and earlier versions.
**Tip:** To detect whether a print dialog was displayed, you can use the `matchMedia` method with the `print` media type.
---
### Browser Support
The numbers in the table indicate the first browser version that fully supports the event.
| Event | Chrome | Edge | Firefox | Safari | Opera |
| :--- | :--- | :--- | :--- | :--- | :--- |
| `onafterprint` | 6.0 | 12.0 | 6.0 | 11.1 | 11.5 |
---
### Syntax
In HTML:
In JavaScript:
```javascript
object.onafterprint = function(){myScript};
Using the addEventListener() method:
```javascript
object.addEventListener("afterprint", myScript);
---
### Technical Details
| | |
| :--- | :--- |
| **Bubbles:** | No |
| **Cancel:** | No |
| **Event type:** | Event |
| **Supported HTML tags:** | `` |
| **DOM Version:** | Level 2 Events |
---
### Example
function afterPrinting() {
alert("This alert box will appear after printing.");
}
YouTip