日期:2014-05-17  浏览次数:20759 次

请问谁用过这个打印代码,如何设计页眉页脚?
请问这个js打印代码,可以自定义设置页眉页脚吗? 我想设置成自己的文字,又或者为空,求高手打救一下..............



VBScript code

<SCRIPT language=JavaScript>

function doPrint(){
var str="<html>";
var article;
var css;
var strAdBegin="<!--NEWSZW_HZH_BEGIN-->";
var strAdEnd="<!--NEWSZW_HZH_END-->";
var strFontSize='【<A href="javascript:doZoom(16)">大</A> <A href="javascript:doZoom(14)">中</A> <A href="javascript:doZoom(12)">小</A>】'
var strdoPrint="doPrint()";
var strTmp;

   css="<style>"
   +"body{font-family:宋体}"
   +"td,.f12{font-size:12px}"
   +".f24 {font-size:24px;}"
   +".f14 {font-size:14px;}"
   +".title14 {font-size:14px;line-height:130%}"
   +".l17 {line-height:170%;}"
   +"</style>";

   str += css;
   str += '<meta http-equiv="content-type" content="text/html; charset=gb2312">';
   str += '<title>'+document.title+'</title>';
   str += "<body bgcolor=#ffffff topmargin=5 leftmargin=5 marginheight=5 marginwidth=5 onLoad='window.print()'>";
   str += "<center><table width=600 border=0 cellspacing=0 cellpadding=0><tr><td align=right valign=bottom><a href='javascript:history.back()'>返回</a> <a href='javascript:window.print()'>打印</a></td></tr></table>";
   str += "<table width=600 border=0 cellpadding=0 cellspacing=20 bgcolor=#EDF0F5><tr><td>";
  
   article=document.getElementById('article').innerHTML;
   if(article.indexOf(strAdBegin)!=-1){
    str +=article.substr(0,article.indexOf(strAdBegin));
    strTmp=article.substr(article.indexOf(strAdEnd)+strAdEnd.length, article.length);
   }else{
    strTmp=article
   }
   str +=strTmp
   str += "</td></tr></table></center>";
   str += "</body></html>";
   document.write(str);
   document.close();

}
</SCRIPT>



------解决方案--------------------