在HTML中有时候我们会用到静态分页,一次拿回一定量的数据结果条目,我们会以形如:第2页,共12页  首页 上一页 下一页 尾页 的方式进行静态分页,以下是该种静态分页的代码,供兄弟姐妹们参考。

function createPageHTML(_nPageCount, _nCurrIndex, _sPageName, _sPageExt){   if(_nPageCount == null || _nPageCount<1){     return;   }   var nCurrIndex = _nCurrIndex || 0;   var pre,next,first,last;   if(_nPageCount==1){   first='首页 '; pre='上一页 '; next='下一页 '; last='尾页 '; }else{  if(_nCurrIndex==0){      pre='上一页 ';      first='首页 '; next='下一页 ';      last='尾页 '; } else{  if(_nCurrIndex==1){    first='首页 '; pre='上一页 ';    if(_nPageCount==2){ next='下一页 '; last='尾页 '; } else{ next='下一页 '; last='尾页 '; }} else{    first='首页 '; pre='上一页 '; if(nCurrIndex+1==_nPageCount){ next='下一页 '; last='尾页 '; } else{ next='下一页 '; last='尾页 '; } }

}

}

document.write("第"+(nCurrIndex+1)+"页,共"+_nPageCount+"页  "+first+pre+next+last); }

createPageHTML(${PAGE_COUNT}, ${PAGE_INDEX}, "${PAGE_NAME}", "${PAGE_EXT}");  

更多推荐

html分页首页上一页下一页,HTML静态分页(形如:首页,上一页,下一页,尾页)...