JSP添加打印部分页面
2014-04-27 17:06 Ball Cactus 阅读(393) 评论(0) 收藏 举报打印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="打印汇总" />
浙公网安备 33010602011771号