如何用按钮实现局部打印功能??

1<input name="print" type="button" value="请装好A4纸后按此处打印"/>

//按钮

1<table border="2" bordercolor="#999999" height="144" width="675">//表格   
2<tr>
3<td>   
4....   
5....   
6</td>
7</tr>
8</table>

如何让按钮只打印出表格!而不打印表格外的东西呢?
用代码应该如何实现?

---------------------------------------------------------------

 1<html>
 2<head>
 3<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"/>
 4<title>看看</title>
 5<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 6<!--media=print 这个属性可以在打印时有效-->
 7<style media="print">   
 8.Noprint{display:none;}   
 9.PageNext{page-break-after: always;}   
10</style>
11<style>   
12.tdp   
13{   
14border-bottom: 1 solid #000000;   
15border-left: 1 solid #000000;   
16border-right: 0 solid #ffffff;   
17border-top: 0 solid #ffffff;   
18}   
19.tabp   
20{   
21border-color: #000000 #000000 #000000 #000000;   
22border-style: solid;   
23border-top-width: 2px;   
24border-right-width: 2px;   
25border-bottom-width: 1px;   
26border-left-width: 1px;   
27}   
28.NOPRINT {   
29font-family: "宋体";   
30font-size: 9pt;   
31}   
32  
33</style>
34</head>
35<body>
36<center class="Noprint">
37<p>
38<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="WebBrowser" width="0">
39</object>
40<input onclick="document.all.WebBrowser.ExecWB(6,1)" type="button" value="打印"/>
41<input onclick="document.all.WebBrowser.ExecWB(6,6)" type="button" value="直接打印"/>
42<input onclick="document.all.WebBrowser.ExecWB(8,1)" type="button" value="页面设置"/>
43</p>
44<p> <input onclick="document.all.WebBrowser.ExecWB(7,1)" type="button" value="打印预览"/>
45</p>
46<hr align="center" noshade="" size="1" width="90%"/>
47</center>
48<table align="center" border="0" cellpadding="2" cellspacing="0" class="tabp" width="90%">
49<tr>
50<td class="tdp" colspan="3">第1页</td>
51</tr>
52<tr>
53<td class="tdp" width="29%"> </td>
54<td class="tdp" width="28%"> </td>
55<td class="tdp" width="43%"> </td>
56</tr>
57<tr>
58<td class="tdp" colspan="3"> </td>
59</tr>
60<tr>
61<td class="tdp" colspan="3"><table border="0" cellpadding="0" cellspacing="0" width="100%">
62<tr>
63<td class="tdp" width="50%"><p>这样的报表</p>
64<p>对一般的要求就够了。</p></td>
65<td> </td>
66</tr>
67</table></td>
68</tr>
69</table>
70<hr align="center" class="NOPRINT" noshade="" size="1" width="90%"/>
71<!--分页-->
72<div class="PageNext"></div>
73<table align="center" border="0" cellpadding="2" cellspacing="0" class="tabp" width="90%">
74<tr>
75<td class="tdp">第2页</td>
76</tr>
77<tr>
78<td class="tdp">看到分页了吧</td>
79</tr>
80<tr>
81<td class="tdp"> </td>
82</tr>
83<tr>
84<td class="tdp"> </td>
85</tr>
86<tr>
87<td class="tdp"><table border="0" cellpadding="0" cellspacing="0" width="100%">
88<tr>
89<td class="tdp" width="50%"><p>这样的报表</p>
90<p>对一般的要求就够了。</p></td>
91<td> </td>
92</tr>
93</table></td>
94</tr>
95</table>
96</body>
97</html>
Published At
Categories with Web编程
comments powered by Disqus