<html>
<body>
<h1>HTML DOM Events</h1>
<h2>The afterprint Event</h2>
<p>Use the addEventListener() method to attach an "afterprint" event to the window object.</p>
<h3>Print this document!</h3>
<p><b>Tip</b>: The keyboard shortcut Ctrl+P prints a page.</p>
<script>
window.addEventListener("afterprint", myFunction);
function myFunction() {
alert("This document is now being printed");
}
</script>
</body>
</html>