打印网页去掉页眉和页脚

来源:互联网 发布:我国云计算相关政策 编辑:程序博客网 时间:2024/04/27 17:26

方式一:

如果你使用的是IE6以及以前的版本,可以使用这个方法

打开浏览器文件->页面设置

在弹出的页面设置对话框中,将页眉输入框中的"&w&b页码,&p/&P"清空则标题信息就不打印了

只去掉&w&b,则只显示页码

将页脚输入框中的"&u&b&d"清空就可以了。

只去掉&u,则下面还会显示打印日期,而不显示网址。

 

方式二:

print打印部分网页,且去掉页眉、页脚 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk" /><title>  </title><link rel="stylesheet" type="text/css" id="css" href="http://bbs.blueidea.com/orumdata/cache/style_2.css" /><Script language="JavaScript"> var hkey_root,hkey_path,hkey_keyhkey_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){}} function doPrint(){PageSetup_Null() ; var str = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>'; str += '<meta http-equiv="Content-Type" content="text/html; charset=gbk" />'; str += '<title>'+document.title+'</title>'; str += '<link rel="stylesheet" type="text/css" href="http://bbs.blueidea.com/orumdata/cache/style_2.css"/>'; str +='</head>'; str +='<body onload="window.print()">'+document.getElementByIdx("printarea").innerHTML + '</body></html>'; document.write(str); document.close(); }</script></head><body><div id="printarea"> 要打印的部分  </div> <input name="bt" type="button" value="打印" onclick="doPrint();" /></body></html> 打印整个网页,不显示页面、页脚 test page print<br>xxxxxxxxxxx<br>yyyyyyyyyyyyyy<br>kkkkkkkkkkkk<br> <Script language="JavaScript"> var hkey_root,hkey_path,hkey_keyhkey_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){}} // 设置页眉页脚为默认值function PageSetup_Default(){try{ var RegWsh = new ActiveXObject("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") ; }catch(e){}} // 打印function PrintPage(){PageSetup_Null() ;window.print() ;PageSetup_Default() ;} </Script><a href="#" onClick="PrintPage();">Print Page</a> 


 

0 0
原创粉丝点击