[quote]此为js打印当前页面的信息内容,操作简单,一目了然[/quote]
<script type="text/javascript">
// JScript 方法 拷入页面即可
function preview1() {
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();
}
</script>
<body>
//在页面上调用js方法
<a href="javascript:preview1();">打印此页</a>
<div style="display: none">
<!--startprint-->
打印信息内容 写在此处、、、
<!--endprint-->
</div>
</body>
本文介绍了一种使用JavaScript实现网页内容打印的方法。通过定义特定的注释标记,该脚本能够精确地选择要打印的内容区域,避免不必要的页面元素被打印出来。用户只需点击页面上的打印链接,即可轻松完成打印。

被折叠的 条评论
为什么被折叠?



