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();
        }

posted on 2009-04-03 21:20  ToKens  阅读(199)  评论(0编辑  收藏  举报