gpt4 book ai didi

javascript - 如何从第二个打印页开始打印网页页脚?

转载 作者:太空宇宙 更新时间:2023-11-03 19:03:28 25 4
gpt4 key购买 nike

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

JavaScript:

if (lineNo > 35) {
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>";
}

HTML:

<style type="text/css" media="print">

div#print-footer {
position: fixed;
right: 14px;
bottom: 0;
background-color: white
}

</style>

最佳答案

隐藏首页页脚

div#print-footer:nth-of-type(1) {
... css for hiding the footer
}

顺便说一下,你不应该使用 id='print-footer' 因为它看起来不止一次出现。使用 class='print-footer' 并在您的 css 中将 # 替换为点 .

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

为打印创建一个全局

pageNo = 1;

并省略首页的页脚

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++;
}

编辑 2:

对于第一个解决方案,this jsfiddle 中的一个简单示例查看第一个 print-footer 是如何隐藏的

关于javascript - 如何从第二个打印页开始打印网页页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11257417/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com