asp实现页面打印功能
加入如下代码在标签前
点击查看代码
<script language=javascript>
function preview() {
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();
window.document.body.innerHTML=bdhtml;
}
</script>
点击查看代码
<!--startprint-->
点击查看代码
<!--endprint-->
然后打印按钮给一个onClick="preview();window.close()"