1.JavaScript打印
<input id="btnPrint" type="button" value="button" onclick="javascript:window.print();" style="color:#00f; font-weight:bold; text-decoration:none;cursor:pointer!important; cursor:hand"/>
可以用样式控制,你想让那块打印就打印,样式如下:
<style type="text/css" media=print>
.noprint{display : none }
</style>
然后使用样式就可以:
<p class="noprint">不需要打印的地方</p>

如果要打印网页中的某一部分,只要把这一部分标记为
<!--startprint--><!---endprint-->中就可以了
=============================================================
2.IE打印
<script language="javascript">

// 打印页面设置
function printsetup() { wb.execwb(8,1);}
// 打印页面预览
function printpreview() { wb.execwb(7,1); }
function printit(){ if (confirm('确定打印吗?')) { wb.execwb(6,6) }}
</script>
</head>
      <body>
      <OBJECT classid="CLSID:8856F961_340A_11D0_A96B_00C04FD705A2"
<link rel=alternate media=print    href="printversion.doc">    height=0 id=wb name=wb width=0></OBJECT>
      <input type=button name=button_print value="打印"        onclick="javascript:printit()">
      <input type=button name=button_setup value="打印页面设置"         onclick="javascript:printsetup();">
      <input type=button name=button_show value="打印预览" onclick="javascript:printpreview();">
      <input type=button name=button_fh value="关闭"       onclick="javascript:window.close();">
          ------------------------------------------------
      关于这个组件还有其他的用法,列举如下:
      WebBrowser.ExecWB(1,1) 打开
      Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口
      Web.ExecWB(4,1) 保存网页
      Web.ExecWB(6,1) 打印
      Web.ExecWB(7,1) 打印预览
      Web.ExecWB(8,1) 打印页面设置
      Web.ExecWB(10,1) 查看页面属性
      Web.ExecWB(15,1) 好像是撤销,有待确认
      Web.ExecWB(17,1) 全选
      Web.ExecWB(22,1) 刷新
      Web.ExecWB(45,1) 关闭窗体无提示

posted on 2010-09-16 08:45  vibratea  阅读(2806)  评论(0编辑  收藏  举报