Javascript DOM onafterprint Event via HTML Tag onafterprint function

Introduction

In JavaScript:

object.onafterprint = function(){
       myScript};

This example uses the HTML DOM to assign an "onafterprint" event to a body element.

View in separate window

<!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>



PreviousNext

Related