Web打印(引用)


From:http://www.cnblogs.com/xuchongyao/archive/2008/07/14/1242213.html


<html>
<head><title>打印</title></head>
<script>
function fn01()
{
 try
 {
 var Wsh=new ActiveXObject("WScript.Shell");
 HKEY_Key="header";
 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
 HKEY_Key="footer";
 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
 }
 catch(e){}
 document.getElementById("div1").style.display="none";
 document.all.WebBrowser.ExecWB(7,1);
 document.getElementById("div1").style.display="block";
}
function fn02()
{
 try
 {
 var Wsh=new ActiveXObject("WScript.Shell");
 HKEY_Key="header";
 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
 HKEY_Key="footer";
 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
 }
 catch(e){}
 document.getElementById("div1").style.display="none";
 document.all.WebBrowser.ExecWB(6,1);
 document.getElementById("div1").style.display="block"; 
}
</script>
<body>
<OBJECT   id=WebBrowser   classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2   height=0   width=0></OBJECT>
<div id="sp1">这里填写打印内容</div>
<div id="div1">
  <input   type=button   value=打印           onclick=fn02()>    
  <input   type=button   value=页面设置   onclick=document.all.WebBrowser.ExecWB(8,1)>                      
  <input   type=button   value=打印预览   onclick=fn01()>
</div>
</body>
</html>
posted @ 2008-07-14 10:27  jhtchina  阅读(147)  评论(0)    收藏  举报