用ASP 写的页码函数,跟淘宝一样滴页码哦, 12....45678.....100 101 102 这种 '##################################################################################################### '输出翻页页码 '参数; currPage;当前页码,RsCount;总记录书 ,PSize=一页显示的内容 'fileLink;文件连接,格式如"?p1=v1&p2=v2&pageNo=" “页码参数=“ 结尾,函数内会在后面接上页码参数 'coder :zhangChuan 20081210 ' update 2009-5-03 :更新分段显示页码 '##################################################################################################### sub printPageGode(currPage,RsCount,PSize,fileLink, className) dim mastPage,forward,after,middle,currRsCountMin,currRsCountMax,currRsCount if RsCount mod Psize =0 Then '得到总页数 mastPage = RsCount/Psize else mastPage = int(RsCount/Psize) + 1 end if if mastPage<=1 Then exit sub currRsCountMin=(currPage-1)*PSize currRsCountMax=(currPage-1)*PSize+PSize if currRsCountMax>RsCount Then currRsCountMax=RsCount currRsCount = currRsCountMin&"-"&currRsCountMax Response.Write " <div id=""pageTurning"">" & vbCrlf Response.Write " <span style=""float:left;line-height:30px;"">共"&RsCount&"条记录,当前显示"&currRsCount&"条</span>" & vbCrlf response.Write ("<div class="""&className&""">") '输出前一页---begin-↓----- if currPage<>1 then ' response.Write("<a href="""&fileLink&currPage-1&"""> 上一页 </a>") else response.Write("<span class=""disabled""> 上一页 </span>") end if '输出前一页---end-↑----- '循环输出页码---begin-↓----- for i=1 to mastPage '1.页码小于15页时 if mastPage<=15 then if i-currPage=0 then '输出当前页 response.Write "<span class=""current"">"&i&"</span>" else response.Write "<a href="""&fileLink&i&""">"&i&"</a>" end if end if '2.总页数大于15页的时 if mastPage>15 then '2.1 当前页在前四页 if currPage<=4 then if i<=4 or mastPage-i<2 Then if i-currPage=0 then '输出当前页 response.Write "<span class=""current"">"&i&"</span>" else response.Write "<a href="""&fileLink&i&""">"&i&"</a>" end if else response.Write "..." i = (mastPage-2) end if end if '2.2 当前页 在四页之后,和后四页之前 if currPage>4 and currPage<mastPage-4 then if (i>=currPage-2 and i<= currPage+2) or i<=2 or i>mastpage-2 then if i-currPage=0 then '输出当前页 response.Write "<span class=""current"">"&i&"</span>" else response.Write "<a href="""&fileLink&i&""">"&i&"</a>" end if end if if i>2 and i<currPage-2 then response.Write "..." i = currpage-3 end if if i>currPage+2 and i<=mastpage-2then response.Write "..." i = mastpage-2 end if end if '2.1 当前页在后四页 if currPage>=mastpage-4 then if i<=2 or i>=mastPage-4 Then if i-currPage=0 then '输出当前页 response.Write "<span class=""current"">"&i&"</span>" else response.Write "<a href="""&fileLink&i&""">"&i&"</a>" end if else response.Write "..." i = (mastPage-5) end if end if end if Next '循环输出页码---end-↑----- '输出后一页---begin-↓----- if currPage-mastPage<>0 then response.Write("<a href="""&fileLink&currPage+1&"""> 下一页 </a>") else response.Write("<span class=""disabled""> 下一页 </span>") end if '输出后一页---end-↑----- response.Write ("</div>") response.Write ("</div>") end sub '输出页码结束 '#####################################################################################################