javascript to print contents of only specific

前端 未结 2 1170
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 05:39

I have tried javascript window.print() It prints the full page content including the print button on the page.

相关标签:
2条回答
  • 2021-01-05 06:24

    Create an iframe and copy your text into it. then you can call the print-function of this, in the iframe embedded window

    or

    see: String.print()

    0 讨论(0)
  • 2021-01-05 06:40

    You require to create new style sheet print.css and set CSS media=print

    for example :

    <style media="screen">
      .noPrint{ display: block; }
      .yesPrint{ display: block !important; }
    </style>
    
    <style media="print">
      .noPrint{ display: none; }
      .yesPrint{ display: block !important; }
    </style>
    

    for more detail : Print a doument with CSS

    0 讨论(0)
提交回复
热议问题