Virtual Pagination script v2.1
Oct 19th, 09': Updated to v2.1, which adds:
wraparound:true/falseoption, which when set to false disables moving back/forth beyond first and last content, respectively
Description: Does your page contain lengthy chunks of text, a series of images, or long forms that dissuade people from reading them top to bottom? This script lets you transform long content on your page into a series of virtual pages, browseable via pagination links. The broken up content pieces are separated simply via arbitrary DIVs (or another block level element of your choice) with a shared class name. Pagination links are "semi automatically" created for the user to navigate to any "page" within the content easily. Watch out, pagination is no longer just a "between pages" affair thanks to this script!
The cornerstone feature of this script is its extreme flexibility when it comes to personalizing the format/look of the content's pagination interface. Instead of letting the script dictate how the links should look, you tell the script instead how and what to show as part of the pagination interface. Whether you want to just display "back/forward" links, switch to images instead, display a drop down, and more, what and how everything is shown is up to you, thanks to special "keywords" you use in your HTML that the script will pick up as having special meaning.
Demos: Five Virtual Pagination demos below:Demo #1: 6 pieces of content, each separated by a "P" element. 2 pieces of content is shown per page. Persistence enabled.
Demo #2: Contains 4 pieces of content, each separated by a "DIV" element. 1 piece of content is shown per page. Custom text defined for pagination links (instead of "1", "2", "3" etc). Persistence enabled.
Demo #3: 4 pieces of content, each separated by a "DIV" element. 1 piece of content is shown per page. Two pagination DIVs defined.
Demo #4: 6 pieces of content, each separated by a "P" element. 1 pieces of content is shown per page. Two pagination DIVs defined. Persistence enabled.
Demo #5: 4 pieces of content, each separated by a "DIV" element. 1 piece of content is shown per page. Custom text defined for pagination links (instead of "1", "2", "3" etc). Persistence enabled.
Step 1: Add the below code and sample CSS to your page:
The code references an external .js file. Download it below:
Step 2: Add the below to the BODY of your page, which contains 5 virtual pagination demos to help you see the syntax:
Time to learn exactly how to apply this script to your content.
Basic Setup information
Setting up this script on any long piece of content on your page is a 1-2-3 process.
Stage 1: Divide your long content into individual parts
using a DIV tag (or any block element. See
contains an arbitrary but shared CSS class name (ie: "
<div style="width: 400px;"> <div class="virtualpage hidepiece"> First Piece within Content " </div> <div class="virtualpage hidepiece"> Second Piece within Content " </div> <div class="virtualpage hidepiece"> Third Piece within Content " </div> </div>
Here I'm using DIVs to contain each content piece. These containers
should contain an arbitrary but shared CSS class (ie: "
plus the CSS class "
hidepiece" that should always be
Now, it's recommended that you throw in an extra DIV that surrounds the
entire content with an explicit width/ height set. This sets the height of the
area in which each piece of content is contained in, to prevent the page from
"bopping" as the user paginates through the pieces of content
with varying heights. That's
what the DIV in gray is for.
Stage 2: Once your content is sliced into individual pieces, you must now define the pagination interface for the content. At its simplest the code for it looks something like this:
<div id="paginatediv" class="paginationstyle"> <a href="#" rel="previous" style="margin-right: 100px">Prev</a> <a href="#" rel="next">Next</a> </div>
The DIV must carry an arbitrary but unique ID (ie: "
help the script identify it in the final step below. Add this pagination
code anywhere on the page as desired (ie: directly below the paginated
content containers in Step 1 above). Inside this DIV you can customize the
pagination interface in limitless ways, using a flexible template system
to assign special meaning to various components inside it. See
Documentation for more info.
Where the two CSS classes in red must correspond to the two classes defined earlier. And that's it for setup, the basic version that is!
Moving on, it's time to look at the Virtual Pagination Documentation, where you'll learn how to do things such as define multiple pagination DIVs for a Virtual Pagination instance, customize the pagination DIVs in a variety of ways, selecting a page by calling the navigate() method or via a URL parameter string, and more.
Table Of Contents
This script consists of an index page plus a supplementary page: