Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从打印的第二页开始打印网页页脚?_Javascript_Html_Css_Printing - Fatal编程技术网

Javascript 如何从打印的第二页开始打印网页页脚?

Javascript 如何从打印的第二页开始打印网页页脚?,javascript,html,css,printing,Javascript,Html,Css,Printing,我正在尝试使用HTML打印页面的页脚。但是,我需要页脚只从第二页开始。将生成的页数因文档而异。到目前为止,它要么出现在每一页中,要么出现在页面的末尾 JavaScript: if(行号>35){ 内容+=”; 内容+=”; 内容+=“参考编号:”+tranId+”; 内容+=”; 内容+=”; } HTML: div#打印页脚{ 位置:固定; 右:14px; 底部:0; 背景颜色:白色 } 隐藏第一页的页脚 div#print-footer:nth-of-type(1) { .

我正在尝试使用HTML打印页面的页脚。但是,我需要页脚只从第二页开始。将生成的页数因文档而异。到目前为止,它要么出现在每一页中,要么出现在页面的末尾

JavaScript:

if(行号>35){
内容+=”;
内容+=”;
内容+=“参考编号:”+tranId+”;
内容+=”;
内容+=”;
}
HTML:


div#打印页脚{
位置:固定;
右:14px;
底部:0;
背景颜色:白色
}

隐藏第一页的页脚

div#print-footer:nth-of-type(1) {
     ... css for hiding the footer
}
if (lineNo > 35) {
  if (pageNo > 1) {
    content += "<div id='print-footer' width=100%>";
    content += "<table cellspacing=0 cellpadding=0 width=100% border=0>";
    content += "<tr><td style='font-family: Times New Roman; font-size:12px;'>Ref No.: " + tranId + "</td></tr>";
    content += "</table>";
    content += "</div>";
  }
  pageNo++;
}
顺便说一句,您不应该使用
id='print-footer'
,因为它看起来似乎存在多次。使用
class='print-footer'
并将css中的
#
替换为点

编辑:添加另一个变量以跟踪页面。如果您愿意,也可以将其用作页码

创建用于打印的全局

pageNo = 1;
并省略第一页的页脚

div#print-footer:nth-of-type(1) {
     ... css for hiding the footer
}
if (lineNo > 35) {
  if (pageNo > 1) {
    content += "<div id='print-footer' width=100%>";
    content += "<table cellspacing=0 cellpadding=0 width=100% border=0>";
    content += "<tr><td style='font-family: Times New Roman; font-size:12px;'>Ref No.: " + tranId + "</td></tr>";
    content += "</table>";
    content += "</div>";
  }
  pageNo++;
}
if(行号>35){
如果(页码>1){
内容+=”;
内容+=”;
内容+=“参考编号:”+tranId+”;
内容+=”;
内容+=”;
}
pageNo++;
}
EDIT2:


对于第一个解决方案,请在中提供一个简单的示例,以查看第一个
打印页脚是如何隐藏的
,请发布与问题相关的代码。理想情况下,除了问题正文中的代码之外,请添加问题的示例。它将帮助我们帮助您。页脚仍然显示在所有页面上。我正在生成的文档现在总共有4页,它出现在所有页面上,因为您正在对其调用
position:fixed
。我注意到您的内容+=似乎编码不正确。例如,您需要在
div
.arttronics内部使用
style=“width:100%”
,在此处复制时,它似乎是一个打字错误。什么决定了第一个打印页面?我建议通过
else
语句使用
height:0%
来回答问题
if
语句,但这不起作用。用另一种可能的解决方案更新答案你能详细说明第一种解决方案吗?它似乎不起作用您的解决方案只隐藏了第一个div。然而,这里的问题是每次打印页脚时,它都会出现在最后一页的底部。重复打印同一文本时,文本会变暗。是否尝试添加
!重要信息
到类型的第n行css,然后特别是隐藏页脚的行?因此,您会得到如下内容#打印页脚:第n个类型(1){可见性:隐藏!重要;}