window.print
2015-07-14 12:36
295 查看
function contentPrint(contentArea) { var initBody = document.body.innerHTML; if ($("div").hasClass("scroll")) { $(".scroll").attr("class", ""); } if (window.matchMedia) { var mediaQueryList = window.matchMedia('print'); mediaQueryList.addListener(function (mql) { if (mql.matches) { document.body.innerHTML = document.getElementById(contentArea).innerHTML; } else { document.body.innerHTML = initBody; } }); } window.onbeforeprint = function () { document.body.innerHTML = document.getElementById(contentArea).innerHTML; } window.onafterprint = function () { document.body.innerHTML = initBody; } window.print(); } <p style="page-break-before: always;"></p> <br style="height: 0; line-height: 0" />
相关文章推荐
- 这是我看过最好的对hibernate的二级缓存解析
- Rational Performance Tester(RPTv8.6) 在launch Schedule 时一直卡在 29%
- java 关于日期
- Leetcode 234 Palindrome Linked List 复杂度为时间O(n) 和空间(1)解法
- 【Lowest Common Ancestor of a Binary Search Tree】cpp
- [LeetCode] Copy List with Random Pointer
- linux系统下查看图片尺寸的命令
- Jquery多次绑定click事件
- XMLHttpRequest对象
- 没钱买珍珠首饰,可以画一个
- Eclipse光标变成黑色方块解决方法
- 将 emacs 用来开发 SML
- 上海联通大数据与机器学习驱动的离网预测模型
- (博客园首发)开源框架knot.js正式发布了,为前端开发带来全新的开发方式--CBS
- JavaScript取得WEB安全颜色列表的方法
- error: Error: No resource found that matches the given name: attr 'actionBarTabStyle'.
- DFS拓扑排序(算法导论思路)
- 面向对象五大原则_基石_开闭原则
- 登录tomcat 时出现错误:tomcat You are not authorized to view this page
- 自定义组合控件Weight(高仿猫眼底部菜单栏)