且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在javascript中打印div内容

更新时间:2023-01-09 19:57:10

In your JS code add style to hide the "in" div <style>#in {display:none}</style>, like this:

function printDiv()
{
var divToPrint=document.getElementById('DivIdToPrint');
var newWin=window.open('','Print-Window','width=400,height=400,top=100,left=100');
newWin.document.open();
    newWin.document.write('<html><head><style>#in {display:none}</style><body   onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){newWin.close();},10);

}

相关阅读

技术问答最新文章