.net打印

<input type="button" onclick="javascript:printit()"></input>//打印整个html网页.

//打印局部html网页 extjs中的例子

 bdhtml = window.document.body.innerHTML;
    startprint = ("<div>");
    endprint = ("</div>");
    printhtml = bdhtml.substr(bdhtml.indexOf(startprint) );
    printhtml = printhtml.substr(0, printhtml.indexOf(endprint));
    window.document.write('<html>');
    window.document.write('<head>');
    window.document.write('<title>打印列表</title>');
    window.document.write('</head>');
    window.document.write('<body><from>');
    window.document.write(printhtml);
    window.document.write('<from></body>');
    window.document.write('</html>');
    window.print();
    window.location.reload();//加载页面

 

posted @ 2015-07-24 17:51  好好學習  阅读(468)  评论(0编辑  收藏  举报