如何避免出现打印弹出窗口并直接打印到默认打印机?

时间:2018-07-14 10:35:07

标签: javascript jquery html printing

我正在尝试打印Div的内容。

下面是我的jshtml代码。

function printContent(el){
	var restorepage = document.body.innerHTML;
	var printcontent = document.getElementById(el).innerHTML;
	document.body.innerHTML = printcontent;
	window.print();
	document.body.innerHTML = restorepage;
}
<h1>My page</h1>
<div id="div1">DIV 1 content...</div>
<button onclick="printContent('div1')">Print Content</button>
<div id="div2">DIV 2 content...</div>
<button onclick="printContent('div2')">Print Content</button>
<p id="p1">Paragraph 1 content...</p>
<button onclick="printContent('p1')">Print Content</button>

我只是想避免出现打印弹出窗口,以便将打印直接转到默认打印机。

0 个答案:

没有答案
相关问题