打印a.jsp的部分页面
- 将影响要打印的内容放到<div id="printcontent">中
- 为想要打印的内容创建样式pirnt.css
- 在a.jsp中添加以下内容:
function printpage() { OpenWindow=window.open("", "_blank"); //重写网页 OpenWindow.document.write("<head>"); OpenWindow.document.write("<TITLE>打印报表</TITLE>"); OpenWindow.document.write("<link href="<%=basePath + "css/print.css"%>" rel="stylesheet" type="text/css" />"); OpenWindow.document.write("</head>"); OpenWindow.document.write("<BODY onload='window.print();'>"); OpenWindow.document.write(document.getElementById('printcontent').innerHTML ); OpenWindow.document.write("</BODY>"); OpenWindow.document.write("</HTML>"); OpenWindow.document.close(); }
最后,添加打印按钮<input onclick="printpage();" type="button" value="打印汇总" />