[英]javascript to print contents of only specific <div>
我试过javascript window.print()
它打印整页内容,包括页面上的打印按钮。
You require to create new style sheet print.css and set CSS media=print
您需要创建新样式表print.css并设置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 更多细节: 使用CSS打印一个doument
List Apart有一篇非常好的文章。
Create an iframe and copy your text into it. 创建一个iframe并将文本复制到其中。 then you can call the print-function of this, in the iframe embedded window 然后你可以在iframe嵌入窗口中调用它的print-function
or 要么
see: String.print() 请参阅: String.print()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.