html或jsp實現列印三種方法
阿新 • • 發佈:2019-02-03
<%@ page language ="java" import="java.util.*" pageEncoding="utf-8" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://" +request.getServerName()+":"+request.getServerPort()+path+ "/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href =" <%=basePath%> "> <title> My JSP 'print.jsp' starting page</title > <meta http-equiv ="pragma" content="no-cache" > <meta http-equiv ="cache-control" content="no-cache" > <meta http-equiv ="expires" content="0" > <meta http-equiv ="keywords" content="keyword1,keyword2,keyword3" > <meta http-equiv ="description" content="This is my page" > <!-- 列印時下列方法生效 --> <style media ="print" > <!-- . Noprint{display: none;} .PageN ext{pag e-break-after:always;} --> </style> <style type ="text/css" > <!-- .STYLE1 {font-size : 12px } --> </style> </head> <body> <br> <table border ='8' width="500" height="500" > <tr> <td>haha</td><td>haha</td><td>haha</td><td>haha</td></tr> <tr><td></ td><td></ td><td></ td><td></ td></tr> <tr><td></ td><td></ td><td></ td><td></ td></tr> </table> <p class ="dis" align="center" > <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id= "WebBrowser" width=0> </OBJECT> <input name =Button onClick=document.all.WebBrowser.ExecWB(1,1) class="Noprint" type=button value=開啟 /> <input name =Button onClick=document.all.WebBrowser.ExecWB(2,1) class="Noprint" type=button value=關閉所有 > <input name =Button onClick=document.all.WebBrowser.ExecWB(4,1) class="Noprint" type=button value=另存為 > <input name =Button onClick=document.all.WebBrowser.ExecWB(6,1) class="Noprint" type=button value=列印 > <input name =Button onClick=document.all.WebBrowser.ExecWB(6,6) class="Noprint" type=button value=直接列印 > <input name =Button onClick=document.all.WebBrowser.ExecWB(7,1) class="Noprint" type=button value=列印預覽 > <input name =Button onClick=document.all.WebBrowser.ExecWB(8,1) class="Noprint" type=button value=頁面設定 > <input name =Button onClick=document.all.WebBrowser.ExecWB(10,1) class="Noprint" type=button value=屬性 > <input name =Button onClick=document.all.WebBrowser.ExecWB(17,1) class="Noprint" type=button value=全選 > <input name =Button onClick=document.all.WebBrowser.ExecWB(22,1) class="Noprint" type=button value=重新整理 > <input name =Button onClick=document.all.WebBrowser.ExecWB(45,1) class="Noprint" type=button value=關閉 > </p> </body> </html>