如何使用 JavaScript 设置元素内的分页符行为?
javascriptobject oriented programmingfront end technology更新于 2024/6/29 21:32:17
使用 JavaScript 中的 pageBreakInside 属性设置元素内的分页符行为。使用 auto 属性在元素内插入分页符。使用 auto 或 avoid 属性值分别在需要时自动在元素内插入分页符或避免分页符。
注意 − 在打印或查看打印预览时可以看到更改。
示例
您可以尝试运行以下代码以使用 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.pageBreakInside = "auto";
}
</script>
</body>
</html>
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

