如何打印HTML页面的一部分? [英] How to print a portion of an HTML page?
本文介绍了如何打印HTML页面的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个html页面我想打印这个html页面的一部分,我知道一个javascript函数打印一个页面,
I have an html page i want to print a portion of this html page, I know a javascript function to print a page,
onClick="javascript:window.print(); return false;
打印页面的一部分?
如果有人有想法,请与我分享。
If anyone has an idea, please share it with me.
推荐答案
您应该为打印介质使用单独的CSS,这样您可以在打印页面时隐藏/显示部分页面。
You should use a separate css for the print media. This allows you to hide/show portions of the page when it gets printed.
html:
<div class="dont-print-that">
blah
</div>
print this!
包括:
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
print.css
print.css
.dont-print-that{display:none;}
一个只有您要打印的内容的新窗口。您可以在弹出式窗口或iframe中执行此操作。我个人认为CSS解决方案更加优雅,但这取决于你。
The other solution is to open a new window with only the content you want to print. You could either do that in a popup or an iframe. Personally I find the CSS solution more elegant, but that's up to you.
这篇关于如何打印HTML页面的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文