Javascript Browser Window print() Method

Introduction

Print the current page:

Click the button to print the current page.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Print this page</button>
<script>
function myFunction() {//from ww  w  .  j a  v a2  s .c  om
  window.print();
}
</script>
</body>
</html>

The print() method prints the contents of the current window.

The print() method opens the Print Dialog Box, which lets the user to select preferred printing options.

window.print();



PreviousNext

Related