HTML DOM pageBreakInside 属性

定义和用法

pageBreakInside 声明一个元素内部是否应当放置分页符。

语法:

  1. Object.style.pageBreakInside=auto|avoid

可能的值

描述
auto 默认。如果必要则在元素内部插入分页符。
avoid 避免在元素内部插入分页符。

实例

本例避免在 id 为 p2 的段落中的 page-break:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function setPageBreak()
  5. {
  6. document.getElementById("p2").style.pageBreakInside="avoid";
  7. }
  8. </script>
  9. </head>
  10. <body>
  11.  
  12. <p>This is a test paragraph.</p>
  13.  
  14. <input type="button" onclick="setPageBreak()"
  15. value="Set page to not break inside the second paragraph" />
  16.  
  17. <p id="p2">This is also a test paragraph. We need some
  18. more text here. This is just filler text.</p>
  19.  
  20. </body>
  21. </html>