在网上找了很多资料,很多都说用下面的方法,但我用了却没去掉页眉页脚,不知道什么原因?
<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(){
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){}
}
</script>

解决方案 »

  1.   

     1<script language="JavaScript">
     2var hkey_key;
     3var hkey_root="HKEY_CURRENT_USER";
     4var hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
     5//设置网页打印的页眉页脚为空
     6function pagesetup_null()
     7{    
     8
     9    var RegWsh = new ActiveXObject("WScript.Shell");
    10    hkey_key="header";
    11    RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
    12    hkey_key="footer";
    13    RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
    14
    15}
    16
    17//设置网页打印的页眉页脚为默认值
    18function pagesetup_default()
    19{
    20  try{
    21    var RegWsh = new ActiveXObject("WScript.Shell");
    22    hkey_key="header";
    23    RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P");
    24    hkey_key="footer";
    25    RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d");
    26  }catch(e){}
    27}
    28</script>
      

  2.   

    看你的标题整得,搞得我还以为jsp跟word一样有页眉页脚呢??
      

  3.   

    最近也遇到这个问题,在此根据我的遭遇建议一下楼主:
    用页面作为打印内容绝对不是个好选择!
    1.网上能搜到的写法大多是需要activeX插件支持的,在客户端操作时需要调安全级别,此麻烦一
    2.用js脚本将控制横打纵打页眉页脚的注册表写入客户端也不可取,且不同浏览器和不同os也不是都一样,此麻烦二
    3.实际打印效果受客户端打印机设置和浏览器打印设置影响,往往楼主在本机上调好了坐标,随便上其他任意一台机器上很可能坐标就全都不对了。目前我那边客户端换了三次,我就改了三次代码,而且是一个人在用,如果是两台机器一起用,恐怕怎么弄都会有一台机器打不准。