62,046
社区成员
发帖
与我相关
我的任务
分享
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();
<html>
<head>
<style type="text/css" media=print>
.noprint{display : none }
</style>
</head>
<body>
<div class="noprint">不打印的部分</div>
<div>打印的部分</div>
<div class="noprint">不打印的部分</div>
</body>
</html>