在网上找的js代码:
<script 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 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 printPart(){
var printArea = document.getElementById('selectid0');
var iframe = document.createElement('IFRAME');
var doc = null;
iframe.setAttribute('style', 'position:absolute;width:0px;height:0px;left:-500px;top:-500px;');
document.body.appendChild(iframe);
doc = iframe.contentWindow.document;
doc.write('<div>' + printArea.innerHTML + '</div>');
doc.close();
iframe.contentWindow.focus();
PageSetup_Null();
iframe.contentWindow.print();
PageSetup_Default() ;
if (navigator.userAgent.indexOf("MSIE") > 0)
{
document.body.removeChild(iframe);
}
}
</script>
可是打印出来的还是有页眉和页脚,都是项目的路径,谁知道怎么回事?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货