English 中文(简体)
ES6 - Page Printing
  • 时间:2024-09-17

ES6 - Page Printing


Previous Page Next Page  

Many times you would pke to place a button on your webpage to print the content of that web page via an actual printer. JavaScript helps you implement this functionapty using the print function of the window object.

The JavaScript print function window.print() prints the current webpage when executed. You can call this function directly using the oncpck event as shown in the following example.

Example


<html> 
   <body> 
      <form> 
         <input type = "button" value = "Print" oncpck = "window.print()"/> 
      </form> 
   </body> 
</html>

The following output is displayed on successful execution of the above code.

page printing Advertisements