📜  使用 HTML 进行打印机打印 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:02.548000             🧑  作者: Mango

代码示例1
function PrintElem() {
    var mywindow = window.open('', 'PRINT');
    mywindow.document.write('Payment Slip');
    mywindow.document.write('');
    mywindow.document.write('
' + '

Payment Slip

' + '

' + $('.mylabelpaymentheader').html() + '

' + '
'); mywindow.document.write('' + '' + '' + '' + '' + '' + '
Name:' + $('.lblName').html() + '
Address:' + $('.lblAddress').html() + '
Meter No:' + $('.lblMeterNo').html() + '
Token:' + $('.lblToken').html() + '
'+ '
' + ''+ ''); mywindow.document.write(''); mywindow.document.close(); // necessary for IE >= 10 mywindow.focus(); // necessary for IE >= 10*/ mywindow.print(); mywindow.close(); return true; }