我想打印一个特定的 div 而不显示预览窗口。请帮忙
function PrintInvoice() {
$(document).ready(function () {
var toPrint = document.getElementById('div_print');
var popupWin = window.open('', '_blank', 'width=1000,location=no,scrollbars=1,tollbar=0,top=0,left=200px,menubar=no,resizable=no');
popupWin.document.open();
popupWin.document.write('<html><body onload="window.print()">')
popupWin.document.write(toPrint.innerHTML);
popupWin.document.write('</html>');
popupWin.document.close();
popupWin.focus();
popupWin.print();
popupWin.close();
});
}
上面的代码首先打开一个新窗口,然后显示打印对话框。我不想打开一个新窗口