Print js+js多页打印
时间: 2023-07-08 20:31:41 浏览: 47
要实现JS多页打印,可以使用以下步骤:
1. 创建一个打印对象:var printWindow = window.open('', '', 'height=600,width=800');
2. 在打印对象中创建一个HTML页面:printWindow.document.write('<html><head><title>Page Title</title></head><body>');
3. 在HTML页面中插入要打印的内容:printWindow.document.write('Content to be printed');
4. 在HTML页面结束标签前插入打印按钮:printWindow.document.write('</body></html><button onclick="window.print();">Print</button>');
5. 关闭HTML页面:printWindow.document.close();
完整的代码如下:
```
function printPages() {
var printWindow = window.open('', '', 'height=600,width=800');
printWindow.document.write('<html><head><title>Page Title</title></head><body>');
printWindow.document.write('Content to be printed');
printWindow.document.write('</body></html><button onclick="window.print();">Print</button>');
printWindow.document.close();
}
```
在页面中调用printPages()函数即可实现多页打印。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)