📜  html 打印 div - Javascript 代码示例

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

代码示例1
function PrintElem(elem)
{
    var mywindow = window.open('', 'PRINT', 'height=400,width=600');

    mywindow.document.write('' + document.title  + '');
    mywindow.document.write('');
    mywindow.document.write('

' + document.title + '

'); mywindow.document.write(document.getElementById(elem).innerHTML); mywindow.document.write(''); mywindow.document.close(); // necessary for IE >= 10 mywindow.focus(); // necessary for IE >= 10*/ mywindow.print(); mywindow.close(); return true; }