IE 自带的WebBrowser 控件打印怎么隐藏页眉页脚
我使用以下的代码来实现打印,打印想隐藏页眉页脚上出现的:页码:1/1等字样,我找的资料说下面的代码可以实现,但是CreateObject("WScript.Shell") 是出错,有人说在asp.net中是受限制的,要下在个东西才行,我不想那样,应该怎么办?有什么好的办法吗?
<input class="button" onclick="pagesetup_null();document.all.WebBrowser.ExecWB(6,1)" type="button" value="打印">
<script language="javascript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
//设置网页打印的页眉页脚为空
function pagesetup_null()
{
var RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite( hkey_root+hkey_path+hkey_key,"" )
hkey_key="\footer"
RegWsh.RegWrite( hkey_root+hkey_path+hkey_key,"" )
}
//设置网页打印的页眉页脚为默认值
function pagesetup_default()
{
var RegWsh = CreateObject("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" )
}
</script>