HTML静态分页(形如:首页,上一页,下一页,尾页)
在HTML中有时候我们会用到静态分页,一次拿回一定量的数据结果条目,我们会以形如:第2页,共12页 首页 上一页 下一页 尾页 的方式进行静态分页,以下是该种静态分页的代码,供兄弟姐妹们参考。
<div class="page"> <!-- a href="tosearch.jsp" target="_blank" class="blue">更多</a -->
<SCRIPT type="text/javascript">
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=‘<span class="blue">首页</span> ‘; pre=‘<span class="blue">上一页</span> ‘; next=‘<span class="blue">下一页</span> ‘; last=‘<span class="blue">尾页</span> ‘; }else{ if(_nCurrIndex==0){ pre=‘<span class="blue">上一页</span> ‘; first=‘<span class="blue">首页</span> ‘; next=‘<a class="blue" href="‘+_sPageName+‘_‘ +(nCurrIndex+1)+‘.‘+_sPageExt+‘">下一页</a> ‘; last=‘<a class="blue" href="‘+_sPageName+‘_‘ + (_nPageCount-1)+‘.‘+_sPageExt+‘">尾页</a> ‘; } else{ if(_nCurrIndex==1){ first=‘<a class="blue" href="‘+_sPageName+‘.‘+_sPageExt+‘">首页</a> ‘; pre=‘<a class="blue" href="‘+_sPageName+‘.‘+_sPageExt+‘">上一页</a> ‘; if(_nPageCount==2){ next=‘<span class="blue">下一页</span> ‘; last=‘<span class="blue">尾页</span> ‘; } else{ next=‘<a class="blue" href="‘+_sPageName+‘_‘ + (nCurrIndex+1)+‘.‘+_sPageExt+‘">下一页</a> ‘; last=‘<a class="blue" href="‘+_sPageName+‘_‘ + (_nPageCount-1)+‘.‘+_sPageExt+‘">尾页</a> ‘; }} else{ first=‘<a class="blue" href="‘+_sPageName+‘.‘+_sPageExt+‘">首页</a> ‘; pre=‘<a class="blue" href="‘+_sPageName+‘_‘+(nCurrIndex -1)+‘.‘+_sPageExt+‘">上一页</a> ‘; if(nCurrIndex+1==_nPageCount){ next=‘<span class="blue">下一页</span> ‘; last=‘<span class="blue">尾页</span> ‘; } else{ next=‘<a class="blue" href="‘+_sPageName+‘_‘ + (nCurrIndex+1)+‘.‘+_sPageExt+‘">下一页</a> ‘; last=‘<a class="blue" href="‘+_sPageName+‘_‘ + (_nPageCount-1)+‘.‘+_sPageExt+‘">尾页</a> ‘; } }
}
}
document.write("第"+(nCurrIndex+1)+"页,共"+_nPageCount+"页 "+first+pre+next+last); }
createPageHTML(${PAGE_COUNT}, ${PAGE_INDEX}, "${PAGE_NAME}", "${PAGE_EXT}"); </SCRIPT> </div>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。