web打印

 

<script type="text/javascript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
//设置网页打印的页眉页脚为空
function pagesetup_null()
{
   try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
   }catch(e){}
}
//设置网页打印的页眉页脚为默认值
function pagesetup_default()
{
   try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")
   }catch(e){}
}
</script>
<OBJECT id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" width="0" ></OBJECT>

 


<input type="button" value="打印" onclick="document.all.WebBrowser.ExecWB(6,1)" style="width: 78px"/>
<input type="button" value="直接打印" onclick="document.all.WebBrowser.ExecWB(6,6)" style="width: 77px"/>
<input type="button" value="页面设置" onclick="document.all.WebBrowser.ExecWB(8,1)" style="width: 79px" disabled="disabled"/>
<input type="button" value="打印预览" onclick="pagesetup_null();document.all.WebBrowser.ExecWB(7,1)" style="width: 77px"/>

 

 

posted @ 2009-06-10 13:16  戒子  阅读(181)  评论(0编辑  收藏  举报