ASP内容分页函数


ASP #分页 #函数2012-04-27 17:29
<%   
'==============================================   
'函数名:contentpage   
'作  用:内容分页   
'参  数:1、ocontent ----- 文章内容   
'   2、olink  ----- 链接   
'==============================================   
  
function contentpage(ocontent, olink)   
    dim outstr, arrcontent, nextpage, arrpage   
    if instr(ocontent, "[nextpage]") <= 0 then  
        outstr = ocontent   
    else  
        nextpage = request("nextpage")   
        arrcontent = split(ocontent, "[nextpage]")   
        arrpage = ubound(arrcontent) + 1   
        if (nextpage = "" or isnull(nextpage) or not isnumeric(nextpage)) then  
            nextpage = 1   
        else  
            nextpage = cint(nextpage)   
        end if  
        if nextpage < 1 then  
            nextpage = 1   
        end if  
        if nextpage > arrpage then  
            nextpage = arrpage   
        end if  
        outstr = arrcontent(nextpage - 1)   
        outstr = outstr "<br>"  
        for iii = 1 to arrpage   
            if iii = nextpage then  
                outstr = outstr "<font color=""red"">"&iii"</font> "  
            else  
                outstr = outstr "<a href="""&olink"nextpage="&iii""">"&iii"</a> "  
            end if  
        next  
    end if  
    contentpage = outstr   
end function  
  
'=================demo==================   
dim sstrhtml, ostrhtml   
sstrhtml = "我的名字叫胡浪[nextpage]胡是古月的胡[nextpage]浪是三点水一个良字的浪[nextpage]不是一个帅哥哦[nextpage]很普通的一个人"  
ostrhtml = "我的名字叫胡浪,胡是古月的胡,浪是三点水一个良字的浪,不是一个帅哥哦,很普通的一个人"  
'=================demo==================   
response.write("------------------- 带分页 ---------------------")   
response.write("<br>")   
response.write(contentpage(sstrhtml, "?"))   
response.write("<br>")   
response.write("------------------- 不带分页 ---------------------")   
response.write("<br>")   
response.write(contentpage(ostrhtml, "?"))   
%>

相关文章

粤ICP备11097351号-1