|
< html>
< body>
< span id=contents>
< span id=splitpage>
< script type="text/javascript">
_currentPage = 2;//設(shè)置當(dāng)前頁碼
_indexContainer = document.all.splitpage;//設(shè)置存放分頁索引號的容器
_contentContainer = document.all.contents;//設(shè)置存放分頁內(nèi)容的容器
_totalPages = 0;//初始化總頁數(shù)
(function pageLoad() {
_indexContainer.innerHTML =pageNo(100,2,10,7).join(" ");
var str="getR("+3+")";
goToPage(100, 3, 10,7,str);
})();
//返回頁碼對象
function pageNo(counts, currentPage, perPage,showIndex,str) {
var perPage = perPage ? perPage : 5;
var pages=0;
pages=counts/perPage+1;
var pageIndex = [];
//插入第一頁標(biāo)識
if(currentPage==1){
pageIndex.push("《《 《 ");
}else{//注意這里是 A標(biāo)簽 我把前面的<去掉了 因為 加上后會讓系統(tǒng)會自動識別成連接無法正常顯示代碼
var str1="a href=\"javascript:goToPage("+counts+", "+1+", "+perPage+","+showIndex+",'"+str+"')\">《《 a href=\"javascript:goToPage("+counts+", "+(currentPage-1>0?currentPage-1:1)+", "+perPage+","+showIndex+",'"+str+"')\">《 ";
pageIndex.push(str1);
}
var cyclCousnts=parseInt(showIndex/2);
for(var i=1;i<=showIndex;i++){
var tmpPage=currentPage>=cyclCousnts?currentPage-cyclCousnts+i-1:i;
if(currentPage==tmpPage)
pageIndex.push("font color=\"red\">"+tmpPage+"");
else if(tmpPage>pages)
continue;
else if(tmpPage<1)
continue;
else{//注意這里是 A標(biāo)簽 我把前面的<去掉了 因為 加上后會讓系統(tǒng)會自動識別成連接無法正常顯示代碼
var str1="a href=\"javascript:goToPage("+counts+", "+tmpPage+", "+perPage+","+showIndex+",'"+str+"')\">"+tmpPage+"";
pageIndex.push(str1);
}
}
if(currentPage==pages){
pageIndex.push(" 》 》》");
}else{//注意這里是 A標(biāo)簽 我把前面的<去掉了 因為 加上后會讓系統(tǒng)會自動識別成連接無法正常顯示代碼
var str1="a href=\"javascript:goToPage("+counts+", "+(currentPage+1>pages?currentPage:currentPage+1)+", "+perPage+","+showIndex+",'"+str+"')\">》 a href=\"javascript:goToPage("+counts+", "+pages+", "+perPage+","+showIndex+",'"+str+"')\">》》 ";
pageIndex.push(str1);
}
return pageIndex;
}
function goToPage(counts, currentPage, perPage,showIndex,str) {
_contentContainer.innerHTML = eval(str);
_indexContainer.innerHTML = pageNo(counts, currentPage, perPage,showIndex,str).join(" ");
}
function getRecord(currentPage){
return "the current pagaea is:"+currentPage;
}
function getR(currentPage){
return "the current page by eval is:"+currentPage;
}
< /script>
< /body>
< /html>
|