This time I will show you how to use JS to implement paging printing, and what are theprecautions for using JS to implement paging printing. The following is a practical case, let’s take a look.
When callingwindow.print(), the printing effect can be achieved, but when there is too much content, page printing is required.
page-break-beforeand
page-break-afterCSS properties will not Modify the display of web pages on the screen. These two properties are used to control how the file is printed.
Listing 14-4 This is the first p.
This is the second p.
This is the third p.
This is the fourth p.
This is the fifth p.
This is the sixth p.
This is the last p.
Description | |
Default value. If necessary, insert a page break before the element | |
Insert a page break before the element | |
Avoid inserting page breaks before elements | |
Insert enough page breaks before elements until there is a blank left page | |
Enough page breaks before the element, all the way to a blank right page | |
Specifies that the setting of the page-break-before attribute should be inherited from the parent element |
I believe you have mastered the method after reading the case in this article, please pay attention for more exciting things Other related articles on php Chinese website!<html> <head> <script type="text/javascript"> function setPageBreak() { document.getElementById("p2").style.pageBreakBefore="always"; } </script> </head> <body> <p>This is a test paragraph.</p> <input type="button" onclick="setPageBreak()" value="Set page-break" /> <p id="p2">This is also a test paragraph.</p> </body> </html>
Recommended reading:
How to deal with Mac installation thrift error due to bison How to correctly handle Taobao cnpm after installing cnpm is not Internal or external commandThe above is the detailed content of How to use JS to implement paging printing. For more information, please follow other related articles on the PHP Chinese website!