Principle of specifying div area for JavaScript printing page: Use window.open() to open a new page (window) in the browser, use window.document.write() to write the content of the specified div area into the new window document, document .close() closes the document, and uses window.print() to call the printer to print the current document.
function myPrint(obj){ //Open a new window newWindow var newWindow=window.open("Print Window","_blank"); //The div to be printed Content var docStr = obj.innerHTML; //Print content is written into newWindow document newWindow.document.write(docStr); //Close document newWindow.document.close (); //Call the printer newWindow.print(); //Close the newWindow page newWindow.close(); }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn