Home >Web Front-end >JS Tutorial >Example of JavaScript printing a specified area of a web page_javascript skills
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.
JavaScript printing function myPrint(obj):
myprint() calling method:
Example code: