利用HTML的iframe標籤實現頁面打印效果
var iframe = document.createElement('IFRAME');
var doc = null;
document.body.appendChild(iframe);
doc = iframe.contentWindow.document;
doc.write('');//放入需要打印的內容,最好拼接爲一個完整的html
doc.close();
iframe.contentWindow.focus();
iframe.contentWindow.print();
屏蔽打印預覽效果
找到Chrome瀏覽器快捷方式,右鍵選擇‘屬性’,在目標欄添加 --kiosk-printing