分页问题
像新浪那样.当一篇文章字多时,就自动分成多页显示.那是怎么做的?有这方面的代码的兄弟分享一下!我在百度里找了好久也没有找到!
程序代码:
<% dim articleStr,CurrentPage,Maxlen,totalLen,i,j,n articleStr="地方官环境口令地方官环境口令地方官环境口令地方官环境口令,地方官环境口令,地方官环境口令地方官环境口令地方官环境口令,地方官环境口令地方官环境口令地方官环境口令,地方官环境口令地方官环境口令地方官环境口令。地方官环境口令地方官环境口令地方官环境口令。地方官环境口令.<br>地方官环境口令地方官环境口令地方官环境口令.地方官环境口令地方官环境口令." Maxlen=20 totalLen=len(articleStr) if totalLen mod Maxlen = 0 then pageCounts=fix(totalLen/Maxlen) else pageCounts=fix(totalLen/Maxlen)+1 end if Response.write "总页数:"&pageCounts&"<br>" CurrentPage=Request("page") if CurrentPage="" then CurrentPage=1 end if if int(CurrentPage)>pageCounts then CurrentPage=int(pageCounts) end if i=(CurrentPage-1)*Maxlen+1 j=Maxlen Response.write mid(articleStr,i,j)&"<br>" if CurrentPage<2 then Response.write "上一页" else Response.write "<a href='?page="&CurrentPage-1&"'>上一页</a>" end if for n = CurrentPage-3 to CurrentPage+3 if n>0 and Clng(n)<=pageCounts then Response.write"<a href='?page="&n&"'>"&n&"</a> " end if next if CuttentPage=pageCounts then Response.write "下一页" else Response.write "<a href='?page="&CurrentPage+1&"'>下一页</a>" end if %>