Web打印

WEB项目中需要用到打印功能

可用以下javascript方法打印某个DIV的内容

    function printPage()
        {
        var newWin = window.open("printer.aspx","","height=800, width=800"); //printer.aspx跳出的打印页
        var titleHTML = document.getElementById("printdiv").innerHTML;   //printdiv要打印的层
        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();
        }

--其实内部核心也是调用IE浏览器的答应功能

原文地址:https://www.cnblogs.com/zhangqifeng/p/1429250.html