x
 
1
<!DOCTYPE html>
2
<title>My Example</title>
3
4
<script>
5
// Wait for DOM to load
6
document.addEventListener("DOMContentLoaded", function(event) {
7
8
  // Put the button into a variable
9
  var e = document.getElementById("print");
10
  
11
  // Wait for user to click the button
12
  e.addEventListener("click", function() {
13
      window.print();
14
  }, false);
15
  
16
});
17
</script>
18
19
<!-- Replace '{action page}' with your own action page to support non-JavaScript users -->
20
<form name="myForm" action="{action page}">
21
  <input id="print" type="button" value="Print this Page">
22
</form>