asp长文章分页


  ' ContentAutoPage.asp
'
用法:<%=ContentPagination(文章内容)%>
const maxPagesize = 2000 ' 设置分页字数
function InsertPageBreak(strText)
dim strPagebreak, s, ss
dim i, IsCount, c, iCount, strTemp, Temp_String, Temp_Array
strPagebreak
= " [hiweb_break] "
s
= strText
if len (s) < maxPagesize then
InsertPageBreak
= s
end if
s
= replace (s, strPagebreak, "" )
s
= replace (s, " &nbsp; " , " <&nbsp;> " )
s
= replace (s, " &gt; " , " <&gt;> " )
s
= replace (s, " &lt; " , " <&lt;> " )
s
= replace (s, " &quot; " , " <&quot;> " )
s
= replace (s, " &#39; " , " <&#39;> " )
if s <> "" and maxPagesize <> 0 and instr ( 1 , s, strPagebreak) = 0 then
IsCount
= True
Temp_String
= ""
for i = 1 to len (s)
c
= mid (s, i, 1 )
if c = " < " then
IsCount
= False
elseif c = " > " then
IsCount
= True
else
if IsCount = True then
if abs ( asc (c)) > 255 then
iCount
= iCount + 2
else
iCount
= iCount + 1
end if
if iCount >= maxPagesize and i < len (s) then
strTemp
= left (s, i)
if CheckPagination(strTemp, " table|a|b>|i>|strong|div|span " ) then
Temp_String
= Temp_String & trim ( cstr (i)) & " , "
iCount
= 0
end if
end if
end if
end if
next
if len (Temp_String) > 1 then Temp_String = left (Temp_String, len (Temp_String) - 1 )
Temp_Array
= split (Temp_String, " , " )
for i = ubound (Temp_Array) to lbound (Temp_Array) Step - 1
ss
= mid (s, Temp_Array(i) + 1 )
if len (ss) > 380 then
s
= left (s, Temp_Array(i)) & strPagebreak & ss
else
s
= left (s, Temp_Array(i)) & ss
end if
next
end if
s
= replace (s, " <&nbsp;> " , " &nbsp; " )
s
= replace (s, " <&gt;> " , " &gt; " )
s
= replace (s, " <&lt;> " , " &lt; " )
s
= replace (s, " <&quot;> " , " &quot; " )
s
= replace (s, " <&#39;> " , " &#39; " )
InsertPageBreak
= s
end function

function CheckPagination(strTemp, strFind)
dim i, n, m_ingBeginNum, m_intEndNum
dim m_strBegin, m_strEnd, FindArray
strTemp
= lcase (strTemp)
strFind
= lcase (strFind)
if strTemp <> "" and strFind <> "" then
FindArray
= split (strFind, " | " )
for i = 0 to ubound (FindArray)
m_strBegin
= " < " & FindArray(i)
m_strEnd
= " </ " & FindArray(i)
n
= 0
do while instr (n + 1 , strTemp, m_strBegin) <> 0
n
= instr (n + 1 , strTemp, m_strBegin)
m_ingBeginNum
= m_ingBeginNum + 1
loop
n
= 0
do while instr (n + 1 , strTemp, m_strEnd) <> 0
n
= instr (n + 1 , strTemp, m_strEnd)
m_intEndNum
= m_intEndNum + 1
loop
if m_intEndNum = m_ingBeginNum then
CheckPagination
= True
else
CheckPagination
= False
exit function
end if
next
else
CheckPagination
= False
end if
end function

function ContentPagination(hiwebstr)
dim ContentLen, maxperpage, Paginate
dim arrContent, strContent, i
dim m_strFileUrl, m_strFileExt, ArticleID
ArticleID
= Request.QueryString( " Info_ID " )
strContent
= InsertPageBreak(hiwebstr)
ContentLen
= len (strContent)
CurrentPage
= Request.QueryString( " Page " )
if CurrentPage = "" then CurrentPage = 0
if instr (strContent, " [hiweb_break] " ) <= 0 then
ArticleContent
= " <div id=""NewsContentLabel"" > " & strContent & " </div><div id=""Message"" ></div> "
else
arrContent
= split (strContent, " [hiweb_break] " )
Paginate
= ubound (arrContent) + 1
if CurrentPage = 0 then
CurrentPage
= 1
else
CurrentPage
= clng (CurrentPage)
end if
if CurrentPage < 1 then CurrentPage = 1
if CurrentPage > Paginate then CurrentPage = Paginate
strContent
= " <div id=""NewsContentLabel"" > " & arrContent(CurrentPage - 1 )

ArticleContent
= ArticleContent & strContent
if UserArticle = True then
ArticleContent
= ArticleContent & " </p></div><div id=""Message"" ></div><p align=""center""> "
else
ArticleContent
= ArticleContent & " </p></div><p align=""center""> "
end if
if IsURLRewrite then
m_strFileUrl
= ArticleID & " _ "
else
m_strFileExt
= ""
m_strFileUrl
= " ?Info_ID= " & ArticleID & " &Page= "
end if
if CurrentPage > 1 then
if IsURLRewrite and (CurrentPage - 1 ) = 1 then
ArticleContent
= ArticleContent & " <a href="" " & ArticleID & m_strFileExt & " "">上一页</a>&nbsp;&nbsp; "
else
ArticleContent
= ArticleContent & " <a href="" " & m_strFileUrl & CurrentPage - 1 & m_strFileExt & " "">上一页</a>&nbsp;&nbsp; "
end if
end if
for i = 1 to Paginate
if i = CurrentPage then
ArticleContent
= ArticleContent & " [ " & cstr (i) & " ]&nbsp; "
else
if IsURLRewrite and i = 1 then
ArticleContent
= ArticleContent & " <a href="" " & ArticleID & m_strFileExt & " "">[ " & i & " ]</a>&nbsp; "
else
ArticleContent
= ArticleContent & " <a href="" " & m_strFileUrl & i & m_strFileExt & " "">[ " & i & " ]</a>&nbsp; "
end if
end if
next
if CurrentPage < Paginate then
ArticleContent
= ArticleContent & " &nbsp;<a href="" " & m_strFileUrl & CurrentPage + 1 & m_strFileExt & " "">下一页</a> "
end if
ArticleContent
= ArticleContent & " </p> "
end if
Response.write(ArticleContent)
end function
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值