- 原生js,不依赖其它库
- 可指定打印(或不打印)区域
- 支持css样式(内联、外联、嵌入)
- 支持input(radio/checkbox/text)、select、textarea值获取
-
引入Print.js
<script src="Print.js"></script>
-
绑定方法
Print('#Dom');
-
指定不打印区域
方法一. 添加no-print样式类
<div class="no-print">不要打印我</div>
方法二. 自定义类名
Print('#Dom',{'no-print':'.do-not-print-me-xxx'});
<div class="do-not-print-me-xxx">不要打印我</div>
将目标区域的dom/css添加到空iframe中,打印该iframe。
- 不支持background-color背景色打印,试试用background-image代替
- 低级浏览器兼容性待验证