标签:
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(); }
标签:
原文地址:http://www.cnblogs.com/ok519/p/4645133.html