<% Function showpage(totalnumber,maxperpage,filename) Dim n If totalnumber Mod maxperpage=0 Then n= totalnumber / maxperpage Else n= totalnumber / maxperpage+1 End If %> <div class="pages"> <% If CurrentPage<2 Then %>//总页数小于2 <a>首页</a> <a>下一页</a> <% Else %> <a href=<% = filename %>?page=1&categoryid=<%=categoryid%> >首页</a> <a href=<% = filename %>?page=<% = CurrentPage-1 %>&categoryid=<%=categoryid%>>下一页</a> <% End If if TotalPages>8 then//如果总页数大于8,则使用1 2 3。。。9这样的形式输出页数。否则全部输出1,2,3,4,5,6,7,8 if currentpage>=3 then//在总页数大于8的情况下,当前页数不小于3的时候输出 for j=currentpage-1 to currentpage %> <% if j=currentpage then//固定当前页在输出的时候是span而不是a %> <span><%=currentpage%></span> <% else %> <a href=<% = filename %>?page=<% =j %>><%=j%></a> <% end if next %> <a href=<% = filename %>?page=<% =currentpage+1 %>&categoryid=<%=categoryid%>><%=currentpage+1%></a> <% else //如果小于3.则固定输出1,2,3 for j=1 to 3 %> <% if j=currentpage then %> <span><%=currentpage%></span> <% else %> <a href=<% = filename %>?page=<% =j %>&categoryid=<%=categoryid%>><%=j%></a> <% end if next end if %> <% if currentpage+4<TotalPages then %>//在总页数大于8且当前页数+4时候输出。。。否则不输出。。。 <a>...</a> <% %> <a href=<% = filename %>?page=<% =currentpage+4 %>&categoryid=<%=categoryid%>><%=currentpage+4 %></a> <% end if else for j=1 to TotalPages %> <% if j=currentpage then %> <span><%=currentpage%></span> <% else %> <a href=<% = filename %>?page=<% =j %>&categoryid=<%=categoryid%>><%=j%></a> <% end if next end if If n-currentpage<1 Then %> <a>下一页</a> <a>尾页</a> <% Else %> <a href=<% = filename %>?page=<% = (CurrentPage+1) %>&categoryid=<%=categoryid%>>下一页</a> <a href=<% = filename %>?page=<% = n %>&categoryid=<%=categoryid%>>尾页</a> <% End If %> </div> <% End Function %>