客戶端靜態(tài)頁(yè)面玩分頁(yè)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<style>
* {
font-size:10.2pt;
font-family:tahoma;
line-height:150%;
}
.divContent
{
border:1px solid red;
background-color:#FFD2D3;
width:500px;
word-break:break-all;
margin:10px 0px 10px;
padding:10px;
}
</style>
</HEAD>
<BODY>
header
<div id="divPagenation"></div>
<div id="divContent"></div>
footer
<SCRIPT LANGUAGE="JavaScript">
<!--
s="<p>女老師竭力向孩子們證明,學(xué)習(xí)好功課的重要性。 </p><p>她說(shuō):“牛頓坐在樹下,眼睛盯著樹在思考,這時(shí),有一個(gè)蘋果落在他的頭上,于是他發(fā)現(xiàn)了萬(wàn)有引力定律,孩子們,你們想想看,做一位偉大的科學(xué)家多么好,多么神氣啊,要想做到這一點(diǎn),就必須好好學(xué)習(xí)?!?</p><p>“班上一個(gè)調(diào)皮鬼對(duì)此并不滿意。他說(shuō):“興許是這樣,可是,假如他坐在學(xué)校里,埋頭書本,那他就什么也發(fā)現(xiàn)不了啦?!?</p><p>女老師竭力向孩子們證明,學(xué)習(xí)好功課的重要性。 </p><p>她說(shuō):“牛頓坐在樹下,眼睛盯著樹在思考,這時(shí),有一個(gè)蘋果落在他的頭上,于是他發(fā)現(xiàn)了萬(wàn)有引力定律,孩子們,你們想想看,做一位偉大的科學(xué)家多么好,多么神氣啊,要想做到這一點(diǎn),就必須好好學(xué)習(xí)?!?</p><p>“班上一個(gè)調(diào)皮鬼對(duì)此并不滿意。他說(shuō):“興許是這樣,可是,假如他坐在學(xué)校里,埋頭書本,那他就什么也發(fā)現(xiàn)不了啦?!?</p><p>女老師竭力向孩子們證明,學(xué)習(xí)好功課的重要性。 </p><p>她說(shuō):“牛頓坐在樹下,眼睛盯著樹在思考,這時(shí),有一個(gè)蘋果落在他的頭上,于是他發(fā)現(xiàn)了萬(wàn)有引力定律,孩子們,你們想想看,做一位偉大的科學(xué)家多么好,多么神氣啊,要想做到這一點(diǎn),就必須好好學(xué)習(xí)。” </p><p>“班上一個(gè)調(diào)皮鬼對(duì)此并不滿意。他說(shuō):“興許是這樣,可是,假如他坐在學(xué)校里,埋頭書本,那他就什么也發(fā)現(xiàn)不了啦。” </p><p>女老師竭力向孩子們證明,學(xué)習(xí)好功課的重要性。 </p><p>她說(shuō):“牛頓坐在樹下,眼睛盯著樹在思考,這時(shí),有一個(gè)蘋果落在他的頭上,于是他發(fā)現(xiàn)了萬(wàn)有引力定律,孩子們,你們想想看,做一位偉大的科學(xué)家多么好,多么神氣啊,要想做到這一點(diǎn),就必須好好學(xué)習(xí)?!?</p><p>“班上一個(gè)調(diào)皮鬼對(duì)此并不滿意。他說(shuō):“興許是這樣,可是,假如他坐在學(xué)校里,埋頭書本,那他就什么也發(fā)現(xiàn)不了啦?!?</p><p>女老師竭力向孩子們證明,學(xué)習(xí)好功課的重要性。 </p><p>她說(shuō):“牛頓坐在樹下,眼睛盯著樹在思考,這時(shí),有一個(gè)蘋果落在他的頭上,于是他發(fā)現(xiàn)了萬(wàn)有引力定律,孩子們,你們想想看,做一位偉大的科學(xué)家多么好,多么神氣啊,要想做到這一點(diǎn),就必須好好學(xué)習(xí)?!?</p><p>“班上一個(gè)調(diào)皮鬼對(duì)此并不滿意。他說(shuō):“興許是這樣,可是,假如他坐在學(xué)校里,埋頭書本,那他就什么也發(fā)現(xiàn)不了啦。” </p>";
function DHTMLpagenation(content) { with (this)
{
// client static html file pagenation
this.content=content;
this.contentLength=content.length;
this.pageSizeCount;
this.perpageLength=100; //default perpage byte length.
this.currentPage=1;
//this.regularExp=/.+[\?\&]{1}page=(\d+)/;
this.regularExp=/\d+/;
this.divDisplayContent;
this.contentStyle=null;
this.strDisplayContent="";
this.divDisplayPagenation;
this.strDisplayPagenation="";
arguments.length==2?perpageLength=arguments[1]:'';
try {
divExecuteTime=document.createElement("DIV");
document.body.appendChild(divExecuteTime);
}
catch(e)
{
}
if(document.getElementById("divContent"))
{
divDisplayContent=document.getElementById("divContent");
}
else
{
try
{
divDisplayContent=document.createElement("DIV");
divDisplayContent.id="divContent";
document.body.appendChild(divDisplayContent);
}
catch(e)
{
return false;
}
}
if(document.getElementById("divPagenation"))
{
divDisplayPagenation=document.getElementById("divPagenation");
}
else
{
try
{
divDisplayPagenation=document.createElement("DIV");
divDisplayPagenation.id="divPagenation";
document.body.appendChild(divDisplayPagenation);
}
catch(e)
{
return false;
}
}
DHTMLpagenation.initialize();
return this;
}};
DHTMLpagenation.initialize=function() { with (this)
{
divDisplayContent.className=contentStyle!=null?contentStyle:"divContent";
if(contentLength<=perpageLength)
{
strDisplayContent=content;
divDisplayContent.innerHTML=strDisplayContent;
return null;
}
pageSizeCount=Math.ceil((contentLength/perpageLength));
DHTMLpagenation.goto(currentPage);
DHTMLpagenation.displayContent();
}};
DHTMLpagenation.displayPage=function() { with (this)
{
strDisplayPagenation="分頁(yè):";
if(currentPage&¤tPage!=1)
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.previous()">上一頁(yè)</a> ';
else
strDisplayPagenation+="上一頁(yè) ";
for(var i=1;i<=pageSizeCount;i++)
{
if(i!=currentPage)
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.goto('+i+');">'+i+'</a> ';
else
strDisplayPagenation+=i+" ";
}
if(currentPage&¤tPage!=pageSizeCount)
strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.next()">下一頁(yè)</a> ';
else
strDisplayPagenation+="下一頁(yè) ";
strDisplayPagenation+="共 " + pageSizeCount + " 頁(yè),每頁(yè)" + perpageLength + " 字符,調(diào)整字符數(shù):<input type='text' value='"+perpageLength+"' id='ctlPerpageLength'><input type='button' value='確定' onclick='DHTMLpagenation.change(document.getElementById(\"ctlPerpageLength\").value);'>";
divDisplayPagenation.innerHTML=strDisplayPagenation;
}};
DHTMLpagenation.previous=function() { with(this)
{
DHTMLpagenation.goto(currentPage-1);
}};
DHTMLpagenation.next=function() { with(this)
{
DHTMLpagenation.goto(currentPage+1);
}};
DHTMLpagenation.goto=function(iCurrentPage) { with (this)
{
startime=new Date();
if(regularExp.test(iCurrentPage))
{
currentPage=iCurrentPage;
strDisplayContent=content.substr((currentPage-1)*perpageLength,perpageLength);
}
else
{
alert("page parameter error!");
}
DHTMLpagenation.displayPage();
DHTMLpagenation.displayContent();
}};
DHTMLpagenation.displayContent=function() { with (this)
{
divDisplayContent.innerHTML=strDisplayContent;
}};
DHTMLpagenation.change=function(iPerpageLength) { with(this)
{
if(regularExp.test(iPerpageLength))
{
DHTMLpagenation.perpageLength=iPerpageLength;
DHTMLpagenation.currentPage=1;
DHTMLpagenation.initialize();
}
else
{
alert("請(qǐng)輸入數(shù)字");
}
}};
// method
// DHTMLpagenation(strContent,perpageLength)
DHTMLpagenation(s,100);
//-->
</SCRIPT>
</BODY>
</HTML>
相關(guān)文章
TypeScript與JavaScript對(duì)比及打包工具比較
這篇文章主要為大家介紹了TypeScript與JavaScript對(duì)比及打包工具比較,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-03-03TypeScript 內(nèi)置高級(jí)類型編程示例
這篇文章主要為大家介紹了TypeScript 內(nèi)置高級(jí)類型編程示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09前端對(duì)接WebSocket與心跳重連實(shí)現(xiàn)
這篇文章主要為大家介紹了前端對(duì)接WebSocket與心跳重連實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07一文詳解webpack中l(wèi)oader與plugin的區(qū)別
這篇文章主要為大家介紹了一文詳解webpack中l(wèi)oader與plugin的區(qū)別詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02JavaScript parseInt0.0000005打印5原理解析
這篇文章主要為大家介紹了JavaScript parseInt0.0000005打印5原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07基于JavaScript ES新特性let與const關(guān)鍵字
這篇文章主要介紹了基于JavaScript ES新特性let與const關(guān)鍵字,let是ECMAScript 2015新增的一個(gè)關(guān)鍵字,用于聲明變量,const關(guān)鍵字用于聲明一個(gè)常量,更多詳細(xì)內(nèi)容,請(qǐng)需要的小伙伴參考下面文章的介紹,希望對(duì)你有所幫助2021-12-12