ciscolee

代码如下:

function PdfPrintDiv() {
    //隐藏不想打印的部分
    document.getElementById("ubtn").style.display="none"; 
    //实现打印
    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();
    //完成后不隐藏
    document.getElementById("ubtn").style.display="block";
}
</script>

在button或者要触发的元素/事件实现创建id"ubtn",调用该PdfPrintDiv()方法,同时,自行实现那些药隐藏。完成打印后显示即可。

分类:

技术点:

相关文章:

  • 2021-08-03
  • 2021-12-22
  • 2021-12-12
  • 2021-11-18
  • 2021-09-06
  • 2021-12-12
  • 2021-11-28
猜你喜欢
  • 2021-12-12
  • 2021-12-29
  • 2021-09-14
  • 2021-12-12
相关资源
相似解决方案