Code
<!DOCTYPE html>
<html>
     <head>
          <title>html tutorial - html5 - html code - html form - In 30Sec by Microsoft Award MVP - | wikitechy HTML onafterprint Attribute</title>
    </head>
    <body onafterprint="OnAfterPrint()">
          <h1><span>html tutorial - </span>Wikitechy HTML onafterprint Attribute</h2>
          <p>Press Ctrl+P to print the page.</p>
         <script>
                function OnAfterPrint(){
                         alert("This document is now being printed");
                 }
        
</script>
   </body>
</html>




Result