Copy codeThe Code is as follows:
// The number of words displayed on each page
PageSize = 5000;
// Paging Mode
Flag = 2; // 1: Automatic paging Based on words 2: Paging based on [NextPage]
// Renewal page
Startpage = 1;
// Navigation display style 0: Regular 1: Direct 3: drop-down
TopShowStyle = 1;
DownShowStyle = 0;
Var currentSet, CutFlag, TotalByte, PageCount, key, tempText, tempPage;
Key = "";
CurrentSet = 0;
Var Text = xmlArticle. selectSingleNode ("// Content"). text;
TotalByte = Text. length;
If (flag = 1)
{
PageCount = Math. round (TotalByte/PageSize );
If (parseFloat ("0." + TotalByte % PageSize)> 0 ){
If (parseFloat ("0." + TotalByte % PageSize) <0.5 ){
PageCount = PageCount + 1;
}
}
Var PageNum = new Array (PageCount + 1 );
Var PageTitle = new Array (PageCount + 1 );
PageNum [0] = 0;
PageTitle [0] = "";
Var sDrv1, sDrv2, sDrv3, sDrv4, sFlag;
Var sDrvL, sTemL;
Var sTem1, sTem2, k;
SFlag = 0;
For (j = 1; j <PageCount + 1; j ++ ){
PageNum [j] = PageNum [J-1] + PageSize;
PageTitle [j] = "";
// Alert (j );
SDrv1 = "<br> ";
SDrv2 = "<BR> ";
SDrv3 = "<Br> ";
SDrv4 = "<bR> ";
SDrvL = sDrv1.length;
For (k = PageNum [j]; k <= TotalByte; k ++ ){
STem1 = Text. substring (PageNum [j]-sDrvL, k );
STemL = sTem1.length;
STem2 = sTem1.substring (sTemL-sDrvL, sTemL)
If (sTem2 = sDrv1 | sTem2 = sDrv2 | sTem2 = sDrv3 | sTem2 = sDrv4)
{
SFlag = sFlag + 1;
PageNum [j] = k;
Break;
}
}
If (PageNum [j]> TotalByte)
{
Break;
}
}
If (j <PageCount)
{
PageNum. length = j;
PageCount = j
}
If (PageCount> 1 & sFlag> 1 & PageCount <sFlag)
{
PageCount = sFlag + 1;
}
}
Else {
// Manual Paging
Var j, sFlag, PageCount, sText;
Var sTitleFlag;
Var PageNum = new Array ();
Var PageTitle = new Array ();
PageSize = 0;
J = 1;
PageNum [0] =-10;
PageTitle [0] = "";
SFlag = 0;
SText = Text;
Do
{
SText = Text. substring (PageNum [J-1] + 10, TotalByte );
SFlag = sText. indexOf ("[NextPage ");
If (sText. substring (sFlag + 9, sFlag + 10) = "= ")
{
STitleFlag = sText. indexOf ("]", sFlag );
PageTitle [j] = sText. substring (sFlag + 10, sTitleFlag );
}
Else {
PageTitle [j] = "";
}
If (sFlag> 0)
{
PageNum [j] = sFlag + PageNum [J-1] + 10;
}
Else {
PageNum [j] = TotalByte;
}
J + = 1;
}
While (PageNum [J-1] <TotalByte );
PageCount = J-1;
}
Function text_pagination (Page ){
Var Output, Byte;
If (Page = null) {Page = 1 ;}
Output = "";
Output = Output + "<table width = 100% height = 30 border = 0 align = center cellpadding = 0 cellspacing = 0> ";
Output = Output + "<tr> ";
Output = Output + "<td height = 1 background = Images/DotLine.gif> </td> ";
Output = Output + "</tr> ";
// Navigation bar of the header Function
Output = Output + "<tr> ";
// Search the text
Output = Output + "<td align = left bgcolor = # f0faff width = '000000'> ";
Output = Output + "<input type = text name = keys onchange = 'key = this. value 'size = 12> <input type = button name = search value = 'search body 'onclick = 'searchkey (); 'style = 'width: 60'> ";
Output = Output + "</td> ";
Output = Output + "<td align = right bgcolor = # f0faff> ";
// Page number display method 1
// Page x: page title
If (Page = 0 | PageCount = 0 ){
Output = Output + "Current: <font color = red> full text display </font> ";
}
Else {
If (TotalByte> PageSize) {Byte = PageNum [Page]-PageNum [Page-1]} else {Byte = TotalByte };
Output = Output + "Page <font color = red>" + Page + "</font> ";
If (PageTitle [Page]! = "")
{
Output = Output + ": <font color = 800000>" + PageTitle [Page] + "</font> ";
}
Output + = '';
}
// Display method 2
// Select from the drop-down menu
// If (PageCount> 0)
//{
// Output = Output + Article_PageNav (2, Page );
// Output = Output + "</td> ";
//}
// Display Mode 3
// Page number selection list
// Output = Output + "<td align = right bgcolor = # f0faff> ";
// Output = Output + Article_PageNav (0, Page );
// Output = Output + "</td> ";
Output = Output + "</tr> ";
Output = Output + "<tr> ";
Output = Output + "<td height = 1 background = Images/DotLine.gif> </td> ";
Output = Output + "</tr> ";
Output = Output + "</table> ";
// Display the body
If (Page = 0 ){
// No Paging
TempText = Text;
}
Else {
// Pagination
If (flag = 1)
// Automatic Paging
{
TempText = Text. substring (PageNum [Page-1], PageNum [Page]);
}
Else {
// Manual Paging
If (PageTitle [Page-1]. length = 0)
{
TempText = Text. substring (PageNum [Page-1] + 10, PageNum [Page]);
}
Else {
TempText = Text. substring (PageNum [Page-1] + 11 + PageTitle [Page-1]. length, PageNum [Page]);
}
}
}
// Layout content
Output = Output + "<div align = center> ";
Output = Output + Article_PageNav (TopShowStyle, Page );
Output = Output + "</div> ";
Output = Output + "<div id = world> ";
Output = Output + tempText;
Output = Output + "</div> ";
Output = Output + "<br> ";
Output = Output + "<div align = center> ";
Output = Output + Article_PageNav (DownShowStyle, Page );
Output = Output + "</div> ";
Article. innerHTML = Output;
If (Page> 1)
{
Document. location. href = '# top ';
}
Eval (document. all. keys). value = key;
If (key! = "") {Searchkey ();}
}
Function searchkey (){
// Body search function
H = "<font class = keyworld> ";
F = "</font> ";
Keyset = new Array ();
Key = document. all. keys. value;
If (key = ""){
Alert ("enter a keyword! ");
Return;
}
Else {
Keyset [0] = tempText. indexOf (key, 0 );
If (keyset [0] <0 ){
Return;
} Else
Temp = tempText. substring (0, keyset [0]);
Temp = temp + h + key + f;
Temp2 = tempText. substring (keyset [0] + key. length, tempText. length );
For (I = 1; I <tempText. length; I ++ ){
Keyset [I] = tempText. indexOf (keys, keyset [I-1] + key. length );
If (keyset [I] <0 ){
Temp = temp + tempText. substring (keyset [I-1] + key. length, tempText. length );
Break;
} Else {
Temp = temp + tempText. substring (keyset [I-1] + key. length, keyset [I]) + h + key + f;
}
}
World. innerHTML = temp;
}
}
Function Article_PageNav (ShowStyle, Page ){
// Display functions by page number
// The parameter is a call style, 0 = simple style, 1 = standard style
Var temp = "";
If (ShowStyle = 0)
// Simple style
{
TempPage = Page;
If (TotalByte> PageSize ){
If (Page-4 <= 1 ){
Temp = temp + "<font face = webdings color = #999999> 9 </font> ";
If (Page <= 1) {temp = temp + "<font face = webdings color = #999999> 7 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (Page-1) + ")> <font face = webdings> 7 </font> </a> ";}
If (PageCount> 10 ){
For (I = 1; I <8; I ++ ){
If (I = Page ){
Temp = temp + "<font color = red>" + I + "</font> ";
} Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
Temp = temp + "...";
}
Else {
For (I = 1; I <PageCount + 1; I ++ ){
If (I = Page ){
Temp = temp + "<font color = red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
}
If (Page = PageCount) {temp = temp + "<font face = webdings color = #999999> 8 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (Page + 1) + ")> <font face = webdings> 8 </font> </a> ";}
If (PageCount <10) {temp = temp + "<font face = webdings color = #999999 >:</font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + PageCount + ")> <font face = webdings >:</font> </a> ";}
}
Else if (Page + 4 <= PageCount ){
Temp = temp + "<a href = javascript: text_pagination (1)> <font face = webdings> 9 </font> </a> ";
Temp = temp + "<a href = javascript: text_pagination (" + (Page-1) + ")> <font face = webdings> 7 </font> </a> ";
If (PageCount> 10 ){
Temp = temp + "..";
For (I = Page-4; I <Page + 4; I ++ ){
If (I = Page ){
Temp = temp + "<font color = red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
Temp = temp + "..";
}
Else {
For (I = 1; I <PageCount + 1; I ++ ){
If (I = Page ){
Temp = temp + "<font color = red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
}
If (Page = PageCount) {temp = temp + "<font face = webdings color = #999999> 8 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (Page + 1) + ")> <font face = webdings> 8 </font> </a> ";}
Temp = temp + "<a href = javascript: text_pagination (" + PageCount + ")> <font face = webdings >:</font> </a> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (1)> <font face = webdings> 9 </font> </a> ";
Temp = temp + "<a href = javascript: text_pagination (" + (Page-1) + ")> <font face = webdings> 7 </font> </a> ";
Temp = temp + ".."
For (I = Page-2; I <PageCount + 1; I ++ ){
If (I = Page ){
Temp = temp + "<font color = red>" + I + "</font> ";
}
Else {
Temp = temp + "<a href = javascript: text_pagination (" + I + ")>" + I + "</a>" + "";
}
}
If (Page = PageCount) {temp = temp + "<font face = webdings color = #999999> 8 </font> ";} else {temp = temp + "<a href = javascript: text_pagination (" + (Page + 1) + ")> <font face = webdings> 8 </font> </a> ";}
Temp = temp + "<font face = webdings color = #999999 >:</font> ";
}
}
Else {
Temp = temp + "<font color = red> 1 </font> ";
}
Temp = temp + "<a href = javascript: text_pagination (0)> show all </a>"
}
Else if (ShowStyle = 1)
// Standard style
{
If (TotalByte> PageSize) {if (Page! = 0) {if (Page! = 1) {temp = temp + "<a href = '# top 'onclick = javascript: text_pagination (" + (Page-1) + ")> <font color = 3366cc> [Previous Page] </font> </a> ";}}}
For (I = 1; I <PageCount + 1; I ++)
{
If (Page = I)
{
Temp = temp + "<font color = 800000> [" + I + "] </font> ";
}
Else {
Temp = temp + "<a href = '# top 'onclick = javascript: text_pagination (" + I + ")> <font color = 3366cc> ["+ I +"] </font> </a> ";
}
}
Temp = temp + "<a name = 'foot'> </a> ";
If (TotalByte> PageSize) {if (Page! = 0) {if (Page! = PageCount) {temp = temp + "<a href = '# top 'onclick = javascript: text_pagination (" + (Page + 1) + ")> <font color = 3366cc> [Next Page] </font> </a> ";}}}
Temp = temp + "<a href = javascript: text_pagination (0)> <font color = 3366cc> show all </font> </a>"
}
Else if (ShowStyle = 2)
// Drop-down menu style
{
Temp = temp + '<select onchange = "text_pagination (this. value)">'
For (I = 1; I <PageCount + 1; I ++)
{
If (Page = I)
{
Temp = temp + "<option value = '" + I + "'selected style = 'color: red'> page" + I +"
}
Else {
Temp = temp + "<option value = '" + I + "'> page" + I + ";
}
If (PageTitle [I]. length! = 0)
{
Temp = temp + ':' + PageTitle [I];
}
Temp = temp + "</option> ";
}
Temp = temp + "</select> ";
}
Return (temp );
}
// Renewal page
Text_pagination (startpage );
-------------- End of paging js Code --------------
------------ Html page, calling pagination js ------------------
Copy codeThe Code is as follows:
<HTML> <HEAD> <TITLE> js paging </TITLE>
<META http-equiv = Content-Type content = "text/html; charset = gb2312">
</HEAD>
<BODY bottomMargin = 0 leftMargin = 0 topMargin = 0 rightMargin = 0>
<TABLE cellSpacing = 1 cellPadding = 5 width = "95%" align = center
Border = 0>
<TBODY>
<TR>
<TD>
<Xml id = xmlArticle>
<Article>
<Info>
<Content>
<! [CDATA [
Let's test the paging process ~~~~~ [NextPage] My score ~~~ [NextPage] [NextPage] Again
]>
</Content>
</Info>
</Article>
</Xml>
<! -- Text paging Js -->
<SCRIPT language = Javascript
Src = "attachments/month_0607/j200674214834.js"> </SCRIPT>
</TD> </TR> </TBODY> </TABLE> </TD> </TR>
</TBODY> </TABLE>