This article offers an easy way to print certain content or full page content via JavaScript. Here we construct a Div content, site field, and full web page content feature in the form of JavaScript.
PrintPageArea() has some JavaScript code that can be easily implemented on the web page for printing. It offers the easiest way to print out a specific web page area.
PrintPageArea() opens a new web page content window and printing option based on the ID element provided. You can use this function to print a specific web page area or full web page content.
function printPageArea(areaID){ var printContent = document.getElementById(areaID); var WinPrint = window.open('', '', 'width=900,height=650'); WinPrint.document.write(printContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); } Use the printPageArea() function on the Print button element event and provide the content area of the div ID that you want to print. printPageArea('elementID')
The print button that will trigger the printPageArea() function by clicking on it.
Print HTML content which needs to be printed.
© Themesgiant.com All rights reserved| 2011-2020