在点击“打印”按钮触发事件中,将不想打印的东西设置为不显示  
  <tr>  
  <td   colspan="2"   id="trPrint"   align="center"><p   align=center>  
  <input   type="button"     onclick="DocPrint();"   value="打印"   name="B5"   class="hh">  
  <input   type="button"   onclick="fh()"   value="返回"   name="B2"     class="hh">  
  </td>  
  </tr>  
  function   DocPrint(){  
  document.all("trPrint").style.display="none";  
  window.print();  
  }

1.用window对象的print方法

<button onClick="window.print()">打印</button>
2.用WebBrowser控件

<object id="WebBrowser" width=0 height=0  
classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object> 
<button onClick="WebBrowser.ExecWB(8,1)">打印</button> 
3.在文档区域执行print命令

<button onClick="document.execCommand('print')">打印</button> 

该文章转载自脚本之家:http://www.jb51.net/html/200703/44/7562.htm

<title>a 与javascript - 打印模式</title>
<style type="text/css">
body,table {font-size: 12px; font-family: Tahoma, Verdana }
</style>
<body leftmargin="80">
<a href='topic.php?forumid=10&amp;filename=570'><img src='images/bsd07/logo.gif' border="0"></a><br />
<script language="JavaScript">
function bmfprint() {
 if (window.print) {
  window.print();
 }
}
</script><strong>标题:</strong> a 与javascript <a href='#' onclick='void(bmfprint());'>[打印本页]</a

posted on 2007-05-09 22:24  mbskys  阅读(595)  评论(0)    收藏  举报