function myprint() {
//直接调用浏览器打印功能
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;
}
简单浏览器打印文件
最新推荐文章于 2023-04-04 15:37:28 发布