In JavaScript:
object.onafterprint = function(){
myScript};
This example uses the HTML DOM to assign an "onafterprint" event to a body element.
<!DOCTYPE html> <html> <body> <p id="demo"></p> <script> document.getElementsByTagName("BODY")[0].onafterprint = function() {myFunction()}; function myFunction() {/*from w w w . jav a 2 s . co m*/ document.getElementById("demo").innerHTML = "This document is now being printed"; } </script> </body> </html>