日期:2014-05-16  浏览次数:20377 次

js实现(可实现局部打印)

http://www.iteye.com/topic/1114154?

?

?

?

?

function doPrint() {
??? bdhtml = window.document.body.innerHTML;
??? sprnstr = "<!--startprint-->";
??? eprnstr = "<!--endprint-->";
??? prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
??? prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
??? window.document.body.innerHTML = prnhtml;
??? window.print();
}

?

<boby>

?<!--startprint-->

?

要打印的内容

?

<!--endprint-->

?

<boby>