精美而实用的网站,关注web编程技术、网站运营、SEO推广,让您轻松愉快的学习

这是一个常见的ASP函数,用于长文章分页,一般多用于文章或新闻系统中,将本函数复制保存到你的函数库中,方便调用。下面青岛星网跟大家分享:ASP长文章自动分页函数代码。

ASP长文章自动分页函数代码

Function AutoPage(content,paramater,pagevar)
contentStr=split(content,pagevar) 
pagesize=ubound(contentStr)
if pagesize>0 then
    If Int(Request("page"))="" or Int(Request("page"))=0 Then
     pageNum=1 
    Else
     pageNum=Request("page") 
    End if 
    if pageNum-1<=pagesize then
     AutoPage=AutoPage&contentStr(pageNum-1)
     AutoPage=AutoPage&"<divmargin-top:10px;text-align:right;padding-right:15px;""><font color=blue>页码:</font><font color=red>"
     For i=0 to pagesize 
      if i=pageNum-1 then 
       AutoPage=AutoPage&"[<font color=red>"&i+1&"</font>] "
      else 
       if instr(paramater,"?")>0 then
        AutoPage=AutoPage&"<a href="""&paramater&"&page="&i+1&""">["&(i+1)&"]</a>"
       else
        AutoPage=AutoPage&"<a href="""&paramater&"?page="&i+1&""">["&(i+1)&"]</a>"
       end if
      end if  
     Next
     AutoPage=AutoPage&"</font></div>"
    else
     AutoPage=AutoPage&"非法操作!页号超出!<a href=javascript:history.back(-1)><u>返回</u></a>"
    end if
   Else
    AutoPage=content
   end if
 End Function
End Class

函数各参数说明:content:文章内容;paramater文章页URL;pagevar:文章分页标识符,比如“##”,请注意标识符不能和文章中的内容部分有冲突,避免分页出错。

Tags:ASP 分页 函数