bob体育官方平台
Javascript实现的分页函数_javascript技巧_脚本之家

/** *分页类构造 *参数nTotalList:总条数 *参数nPageSize:每页呈现条数 *参数nPageNum:当前页码 *参数sPageUrl:分页链接的U传祺L,页码以[pn]代替他,输出时将被轮流为实在页码 *参数nPageListSize:页码列表中显得的最多页码条数。该参数可总结,暗中同意100 */ functionPagination(nTotalList,nPageSize,nPageNum,sPageUrl,nPageListSize){ this.totalList=nTotalList; this.pageSize=nPageSize; this.pageNum=nPageNum; if this.totalPages=1; else this.totalPages=Math.floor/this.pageSize+1); this.pageUrl=sPageUrl; if this.pageListSize=nPageListSize; else this.pageListSize=100; } /** *扭转分页,将HTML直接出口 *无参数 *无再次回到值 */ Pagination.prototype.generate=function(){ varoutput=""; output+="

"; output+="共"+this.totalList+"条每页"+this.pageSize+"条当前第"; output+=""; varfirstPage=this.pageNum-Math.floor; if firstPage=1; varlastPage=firstPage+this.pageListSize-1; if(lastPage>this.totalPagesState of Qatar{ lastPage=this.totalPages; firstPage=lastPage-this.pageListSize+1; if firstPage=1; } if{ output+="1"; if output+="…"; } for(varp=firstPage;p<=lastPage;p++卡塔尔(قطر‎{ output+=""+p+""; } if(lastPage…"; output+=""+this.totalPages+""; } if(this.pageNum>this.totalPages卡塔尔国 output+="页码超出范围"; output+=""; output+="/"+this.totalPages+"页"; if{ output+="[首页]"; output+="[上页]"; } else{ output+="[首页]"; output+="[上页]"; } if(this.pageNum==this.totalPages){ output+="[下页]"; output+="[尾页]"; } else{ output+="[下页]"; output+="[尾页]"; } output+="

"; document.writeln; }

返回顶部