<html>
<head>
<style media=print>
/*
* @breif: 用本樣式在打印時(shí)隱藏非打印項(xiàng)目
*/
.Noprint
{
display:none;
}
/*
* @breif: 控制分頁(yè)
*/
.PageNext
{
page-break-after: always;
}
</style>
<script type="text/javascript">
var HKEY_root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\\Software\\microsoft\\Internet Explorer\\PageSetup\\";
//設(shè)置網(wǎng)頁(yè)打印的頁(yè)眉頁(yè)腳為空
function PageSetup_Null()
{
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)
{
alert(e.message);
}
}
//設(shè)置網(wǎng)頁(yè)打印的頁(yè)眉頁(yè)腳為默認(rèn)值
function PageSetup_Default()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b頁(yè)碼,&p/&P");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
}
catch(e)
{
alert(e.message);
}
}
</script>
</head>
<body>
<p>Web.ExecWB(2,1):關(guān)閉現(xiàn)在所有的IE窗口,并打開一個(gè)新窗口</p>
<p>webBrowser.ExecWB(1,1): 打開</p>
<p>Web.ExecWB(4,1): 保存網(wǎng)頁(yè)</p>
<p>Web.ExecWB(6,1): 打印</p>
<p>Web.ExecWB(7,1): 打印預(yù)覽</p>
<p>Web.ExecWB(8,1): 打印頁(yè)面設(shè)置</p>
<p>Web.ExecWB(10,1): 查看頁(yè)面屬性</p>
<p>Web.ExecWB(15,1): 好像是撤銷,有待確認(rèn)</p>
<p>Web.ExecWB(17,1): 全選</p>
<p>Web.ExecWB(22,1): 刷新</p>
<p>Web.ExecWB(45,1): 關(guān)閉窗體無提示</p>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<center class="Noprint" >
<br>
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<br>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<br>
<input type=button value=頁(yè)面設(shè)置 onclick=document.all.WebBrowser.ExecWB(8,1)>
<br>
<input type=button value=打印預(yù)覽 onclick=document.all.WebBrowser.ExecWB(7,1)>
<br>
</center>
<br>
<input type="button" value="清空頁(yè)碼" onclick=PageSetup_Null()>
<br>
<input type="button" value="恢復(fù)頁(yè)碼" onclick=PageSetup_Default()>
</body>
</html>