WebBrowser设置打印页眉页眉和页边距

webbrowser,居然被用作套打。。。。。。
由于是套打,格式要求很严格,页眉页脚、页边距等等等等。
在网上找到下列代码,做适当修改后基本上能满足要求了,但是由于是用JS修改注册码,因此和客户端的IE设置有很大关系,必须要求客户IE允许 Activex。如果不允许,var Wsh=new ActiveXObject("WScript.Shell");将抛出一个异常。
<script language="JavaScript" 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 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,"");
HKEY_Key="margin_bottom";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");
HKEY_Key="margin_left";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");
HKEY_Key="margin_right";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");
HKEY_Key="margin_top";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");
}
catch(e){
    //alert(e);
}
}
//设置网页打印的页眉页脚为默认值
function PageSetup_Default()
{  
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
}
catch(e){}
}
    </script>

转载于:https://www.cnblogs.com/interdrp/archive/2009/04/20/1440002.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值