1. Technology

How can I set up automatic pagination in my Web pages?

By

Question Mark Key

Question Mark Key

Image courtesy hdoddema from StockXchng #619007.
Question: How can I set up automatic pagination in my Web pages?
Ken asks:
I have been trying to create a site with ... individual pages (with next links) but the text was in three columns and flowed from page to page if the article was longer than the first page. I would truly love to keep people from having to scroll through some of my long writings and would like my journal to resemble book or newspaper pages where the story flows from one page to the next (without my having to figure out where to cut the article and paste it into the next page. MS Publisher does this kind of thing for printed pages, but I SURE would like to do that with a web site.
Answer:

What you're asking for sounds like a scripting problem - as it's not really possible to automate this in HTML/CSS.

The problem with what you're asking about is the concept of a "page". HTML doesn't have a "page" concept when displaying in a Web browser, because the window scrolls and everyone has their browser open at a different size/resolution. In other words, what might be a screenful of text for you might be only half a windows worth for me.

Here's how I might script it (Keep in mind that there is some "hand waving" in this pseudo-code, as I don't know how the dimensions math would be done):

  1. Put the content in a database or datafile separate from the Web page
  2. Build a template that has a place holder for the content - this will be used for every page of the document
  3. Write some JavaScript that gets the dimensions of the current browser window
  4. Do some math (this is the hand waving part) to determine how many words to include on each page based on the browser dimensions
  5. Pull the page content from the DB, pulling only the number of words determined in step 4.
  6. Based on the number of words in the article, that will tell you how many pages there should be, so use some more JavaScript to create pagination links (These would be links to the same page, but with a parameter like ?page=2 for the script to read and grab the second or third batch of words)

Ask Yourself if You Really Need the Pagination

The other thing to keep in mind is that multiple pages (versus one long page) isn't as important as it used to be. According to Jakob Nielsen (#6 on the list)

most Web users now know that pages scroll and that important links sometimes are not visible "above the fold."

In other words, if the content appears to continue on below the bottom of the window, your customers will scroll to read it (unless they aren't interested in it).

In my own experience I've found that when I paginate an article, the readership drops off by 50% after every page. Part of this is, I'm sure, because the article didn't cover what they needed. But some of it is just because people don't like to click to continue. Scrolling is a lot less user-intensive - chances are their mouse is already in the scrollbar of the browser. To click they have to move it. Of course they have to move it to click "Back" as well, but the back button is always in the same place, so it's not hard to find.

©2014 About.com. All rights reserved.