您的位置:首页 > 其它

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" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: