js实现局部打印

一般是通过 media=“print” 样式表进行格式化:对<style media="print">、<link media="print">的用法合理应用,但是media="print"是不被网页所显示的,只能在打印的效果上存在,这样就可以设置出打印效果和在网页上所显示的不一样。
eg:
在原页面显示,打印时不显示:noprint
在原页面不显示,打印时显示:_print

<style>
 ._print{display:none;}
</style>
<style media="print">
 @page {
   size: auto;  /* auto is the initial value */
   margin: 0mm 10mm; /* this affects the margin in the printer settings */
 }
 .noprint{display: none;}/* 在打印时隐藏 */
 ._print{display:block;}/* 在打印时显示 */
</style>

注意点:切记<style>要写在<style media="print">前才生效

补充:打印
1)可以用引入iframe框架的方法

<iframe src="reportOverviewPrint.html" style="width:100%; min-width: 900px;height:700px;" runat="server" frameborder="no" border="0" scrolling="no" allowtransparency="yes" id="printId"></iframe>

把需要打印的界面写入reportOverviewPrint.html,不需要打印的部分写在原html即可
2)引用jQuery.print.js
jQuery简单易用的网页内容打印插件jQuery.print

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值