國外的核心代碼:
復制代碼代碼如下: for counter = 1 to lastpage
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&""&"&page="&counter&""">"&counter&"</a>"
end if
next
elseif lastpage >= 7 + (adjacents * 2) then 'enough pages to hide some
'close to beginning only hide later pages
if page < 1 + (adjacents * 3) then
for counter = 1 to (4 + (adjacents * 2))-1
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
end if
next
pagination = pagination & "..."
pagination = pagination & "<a href="""&targetpage&""&"&page="&lpm1&""">"&lpm1&"</a>"
pagination = pagination & "<a href="""&targetpage&""&"&page="&lastpage&""">"&lastpage&"</a>"
'in middle hide some front and some back
elseif lastpage - (adjacents * 2) > page AND page > (adjacents * 2) then
pagination = pagination & "<a href="""&targetpage&"&page=1"">1</a>"
pagination = pagination & "<a href="""&targetpage&"&page=2"">2</a>"
pagination = pagination & "..."
for counter = (page - adjacents) to (page + adjacents)
if counter = page then
pagination = pagination & "<span class=""current"">"&counter&"</span>"
else
pagination = pagination & "<a href="""&targetpage&"&page="&counter&""">"&counter&"</a>"
end if
next
pagination = pagination & "..."
pagination = pagination & "<a href="""&targetpage&"&page="&lpm1&""">"&lpm1&"</a>"
pagination = pagination & "<a href="""&targetpage&"page="&lastpage&""">"&lastpage&"</a>"
'close to end only hide early pages
else
pagination = pagination & "<a href="""&targetpage&"&page=1"">1</a>"<