js打印事件

 1 function preview() {
 2     bdhtml = window.document.body.innerHTML;
 3     sprnstr = "<!--startprint-->";
 4     eprnstr = "<!--endprint-->";
 5     prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
 6     prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
 7     window.document.body.innerHTML = prnhtml;
 8     window.print();
 9     //prnform.htext.value=prnhtml;
10     //prnform.submit();
11     //alert(prnhtml);
12 }
原文地址:https://www.cnblogs.com/zzz7/p/11915348.html