javascript打印层

 今天在公司做项目,头说要做个打印,这个不是很熟,于是到网上找了些资料,整理如下

     function printPage()
        {
        var newWin = window.open("printer.aspx","","height=800, width=800");
        var titleHTML = document.getElementById("printdiv").innerHTML;
        newWin.document.write(" <html>");
        newWin.document.write(" <body style='text-align:center'>");
        newWin.document.write(" <h2>财务往来 </h2>");
        newWin.document.write(titleHTML);
        newWin.document.write(" </body>");
        newWin.document.write(" </html>");
        newWin.document.location.reload();
        newWin.print();
        newWin.close();
        }

原文地址:https://www.cnblogs.com/myssh/p/1429243.html