在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
最近网站改版正好发现原来的分页不带数字的,只有首页 上页 下页 末页 然后是select的跳转,都是以前比较流行的,而现在比较流行的是数字分页在中间,正好研究并分享下,需要的朋友可以参考下 效果: 国外的核心代码: 复制代码 代码如下: <% 'digg style pagination script in asp.. written by Moazam... http://www.moazam.com/2007/03/30/asp-digg-style-pagination-script/ function getPaginationString(page, totalitems, limit, adjacents, targetpage) 'defaults if not isnumeric(adjacents) then adjacents = 1 end if if not isnumeric(limit) then limit = 15 end if if not isnumeric(page) then page = 1 end if if targetpage = "" then targetpage = "/" end if margin = "" padding="" 'other vars prev = page - 1 'previous page is page - 1 nextPage = page + 1 'nextPage page is page + 1 lastpage = Ceil(totalitems , limit) 'lastpage is = total items / items per page, rounded up. lpm1 = lastpage - 1 'last page minus 1 ' Now we apply our rules and draw the pagination object. ' We're actually saving the code to a variable in case we want to draw it more than once. pagination = "" if lastpage > 1 then pagination = pagination & "<div class=""pagination""" if margin <> "" OR padding <> "" then pagination = pagination & " style=""" if margin <> "" then pagination = pagination & "margin: margin" end if if padding <> "" then pagination = pagination & "padding: padding" end if pagination = pagination & """" end if pagination = pagination & ">" 'previous button if page > 1 then pagination = pagination & "<a href="""&targetpage&"&page="&prev&""">Prev</a>" else pagination = pagination & "<span class=""disabled"">Prev</span>" end if 'pages if lastpage < 7 + (adjacents * 2) then 'not enough pages to bother breaking it up for counter = 1 to lastpage 完整打包代码:pagination(ogeek.net).rar 看了有些头晕,还是看点简单的吧,asp与php思想差不多啊,参考了dedecms的修改方法 核心代码: 复制代码 代码如下: ps=cint(pageno)-2 if ps<1 then ps=1 end if pe=clng(pageno)+5 if pe>mpage then pe=mpage for i=ps to pe if i=pageno then lb=lb&"<strong>"&i&"</strong>" else lb=lb&"<a href=""/list/list_"&theid&"_"&i&".htm"">"&i&"</a>" end if next 完整代码: 复制代码 代码如下: pageno=cint(currentPage) if cint(pageno)>1 then lb=lb&"<a href=/list/list_"&theid&"_1.htm title=""首页"">首页</a>" else lb=lb&"<a href='#'>首页</a>" end if if cint(pageno)>1 and cint(pageno) then lb=lb&"<a href=/list/list_"&theid&"_"&pageno-1&".htm title=""上页"">上页</a>" else lb=lb&"<a href='#'>上页</a>" end if ps=cint(pageno)-2 if ps<1 then ps=1 end if pe=clng(pageno)+5 if pe>mpage then pe=mpage for i=ps to pe if i=pageno then lb=lb&"<strong>"&i&"</strong>" else lb=lb&"<a href=""/list/list_"&theid&"_"&i&".htm"">"&i&"</a>" end if next if cint(pageno)<mpage and mpage>1 then |
请发表评论