revision:
This 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.
Supported HTML tag:<body>
<element onafterprint="script"></element>
script: the script to be run on onafterprint
Tip: Keyboard shortcuts, such as Ctrl+P sets the page to print.
<body onafterprint="myFunction()"> <h3>Try to print this document</h3> <p class="spec">Tip: Keyboard shortcuts, such as Ctrl+P sets the page to print.</p> <script> function myFunction() { alert("This document is now being printed"); } </script>