如何通过 JavaScript 设置元素之前的分页行为?
在 JavaScript 中使用pageBreakBefore 属性可以设置元素之前的分页行为。使用always 属性可以在元素之前插入分页符。
注意− 更改内容在打印或查看打印预览时可见。
示例
可以尝试运行以下代码,以通过 JavaScript 返回元素之前的分页行为−
<!DOCTYPE html>
<html>
<body>
<h1>Heading 1</h1>
<p>This is demo text.</p>
<p>This is demo text.</p>
<p id = "myFooter">This if footer text.</p>
<button type="button" onclick = "display()">Set page-break</button>
<script>
function display() {
document.getElementById("myFooter").style.pageBreakBefore = "always";
}
</script>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP