打印

来源:互联网 发布:python 矩阵计算 编辑:程序博客网 时间:2024/05/02 14:01

//打印的方法

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

 

<!--  页面需引用的地方-->

<!--startprint-->

<!--  需打印的数据 -->
<div id="printData"></div>
<!--endprint-->

原创粉丝点击