<style type="text/css" media="print"> @page { size: auto; /* 去除页眉页脚auto is the initial value */ margin: 0mm; this affects the margin in the printer settings */ } @media print { /* 添加背景色 */ -webkit-print-color-adjust: exact; } </style>
<script type="text/javascript"> function doPrint() { //bdhtml=window.document.body.innerHTML; //sprnstr="<!--startprint-->"; //eprnstr="<!--endprint-->"; //prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); //prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); document.getElementById("printBtn").style.display = "none"; // 隐藏打印按钮 prnhtml =document.getElementById("context").innerHTML; window.document.body.innerHTML=prnhtml; window.print(); } </script>