␡
- Creating Pages from Linear HTML Text
- Getting Started
- Solution Overview
- Test Drive
Like this article? We recommend
Getting Started
As usual, the most difficult part of the problem is the specifications—you need to know which parts of the HTML document should be paginated (for example, you want to keep the menus and navigation bars intact) and which HTML elements constitute the pagination boundaries. In the code examples throughout this article, we’ll assume the following:
- The document contains a single H1 tag.
- We’ll paginate the content of the parent element of the H1 tag. If you use CSS-based layout, the parent element would be the document BODY tag or a layout DIV tag. If your content uses a table-based layout, the parent element would be a table cell.
- The pagination will start immediately after the H1 tag; everything preceding that tag will be left intact.
- The first page will consist of all the text between the H1 element and the first H2 element, and subsequent pages will start at H2 tags.
The following sections provide detailed explanations of the JavaScript code that converts linear web content into page-structured content.