ITeye博客

javascript:window.print() 打印

thomas0988 · 2015-04-17 17:03 · 前台 · Web前端 · Markdown

1.JavaScript打印
<input id="btnPrint" type="button" value="button" onclick="javascript:window.print();" style="color:#00f; font-weight:bold; text-decoration:none;cursor:pointer!important; cursor:hand"/>
可以用样式控制,你想让那块打印就打印,样式如下:
<style type="text/css" media=print>
.noprint{display : none }
</style>
然后使用样式就可以:
<p class="noprint">不需要打印的地方</p>

如果要打印网页中的某一部分,只要把这一部分标记为 
<!--startprint--><!---endprint-->中就可以了

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。