![]() |
Definition and UsageThe 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 SupportNote: In IE/Edge, the onafterprint attribute occurs before the print dialogue box, instead of after. Syntax
Attribute Values
Technical Details
|
Example:
HTML
<body onafterprint="myFunction()">
Example:
HTML
<!DOCTYPE html>
<html>
<body onafterprint="myFunction()">
<h1>Try to print this document</h1>
<p><b>Tip:</b> Keyboard shortcuts, such as Ctrl+P sets the page to print.</p>
<p><b>Note:</b> The onafterprint event is not supported in Safari and Opera.</p>
<p><b>Note:</b> In IE, the onafterprint event occurs before the print dialogue box, instead of after.</p>
<script>
function myFunction() {
alert("This document is now being printed");
}
</script>
</body>
</html>
|
window event attributes |
What is HTML onafterprint Event Attribute | Window Event Attributes |
How to create HTML onafterprint Event Attribute | Window Event Attributes |
How to Execute a JavaScript when a page has started printing, or if the print dialogue box has been closed | Window Event Attributes |
Read Full: | Window Event Attributes |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | Window Event Attributes |
Uploaded by: | Admin |
Views: | 24 |
Reffered: https://www.w3schools.com/tags/ev_onafterprint.asp