function PdfPrintDiv() {
//隐藏不想打印的部分
document.getElementById("id").style.display="none";
//实现打印
let bdhtml = window.document.body.innerHTML; //将dom元素转化为html
let sprnstr = "<!--startprint-->";
let eprnstr = "<!--endprint-->";
let prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
window.document.body.innerhtml = prnhtml;
window.print();
//完成后不隐藏
document.getElementById("id").style.display="block";
}
</script>
js实现打印功能
最新推荐文章于 2024-07-11 08:47:19 发布