javascript实现window.print()去除页眉页脚

 更新时间:2014年12月30日 16:45:56   投稿:hebedich  
这篇文章主要介绍了javascript实现window.print()去除页眉页脚的方法以及各参数的设置技巧,需要的朋友可以参考下

打印时去除页眉页页脚 打印前加入下面代码即可 var HKEY_Root,HKEY_Path,HKEY_Key;

复制代码 代码如下:

HKEY_Root="HKEY_CURRENT_USER";

HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";

var head,foot,top,bottom,left,right;

  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";

//设置下页边距(0) 根据你自己要设置的填入

Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");

 HKEY_Key="margin_left";

//设置左页边距(0) 根据你自己要设置的填入

Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"1");

 HKEY_Key="margin_right";

//设置右页边距(0)

Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0");

 HKEY_Key="margin_top";

//设置上页边距(8)

Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"1");

相关文章

最新评论