实现asp长文章自动分页插件

时间:2011-02-26 13:51:00 

这是fenye.asp具体代码:


以下是引用片段:




<%
Const maxPagesize=1000 '设置分页字数
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
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
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("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"" class=""NewsContent"">" & strContent & "</div><div id=""Message"" class=""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"" class=""NewsContent"">"& arrContent(CurrentPage - 1)
ArticleContent = ArticleContent & strContent
If UserArticle = True Then
ArticleContent = ArticleContent & "</p></div><div id=""Message"" class=""Message""></div><p align=""center""><b>"
Else
ArticleContent = ArticleContent & "</p></div><p align=""center""><b>"
End If
If IsURLRewrite Then
m_strFileUrl = ArticleID & "_"
Else
m_strFileExt = ""
m_strFileUrl = "?id=" & ArticleID & "&Page="
End If
If CurrentPage > 1 Then
If IsURLRewrite And (CurrentPage-1) = 1 Then
ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """>上一页</a> "
Else
ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & CurrentPage - 1 & m_strFileExt & """>上一页</a> "
End If
End If
For i = 1 To Paginate
If i = CurrentPage Then
ArticleContent = ArticleContent & "<font color=""red"">[" & CStr(i) & "]</font> "
Else
If IsURLRewrite And i = 1 Then
ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """>[" & i & "]</a> "
Else
ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & i & m_strFileExt & """>[" & i & "]</a> "
End if
End If
Next
If CurrentPage < Paginate Then
ArticleContent = ArticleContent & " <a href="""& m_strFileUrl & CurrentPage + 1 & m_strFileExt & """>下一页</a>"
End If
ArticleContent = ArticleContent & "</b></p>"
End If
Response.Write(ArticleContent)
End Function
%>

ASP长文章内容自动分页函数

主要功能:自动将长文章内容分页显示,可自由设定分页字数,且不会截断HTML代码。

适用范围:文章内容自动分页插件适用于所有ASP程序。

使用方法:

1.下载附件中的文件,将它解压上传到您的网站根目录fenye.rar (1.42 KB)

2.在需要分页的页面最顶部调用刚刚上传的文件。调用代码 <!--include file="fenye.asp"-->

3.在内容显示处 将原来的显示代码替换为: <%=ContentPagination(您以前的内容显示变量)%>。

标签:插件,分页,asp
0
投稿

猜你喜欢

  • 能否用显示/隐藏层来控制FLASH播放与停止

    2008-10-27 14:08:00
  • mysql存储过程学习总结

    2011-07-04 12:03:53
  • XHTML1.0与HTML兼容指引16条[译]

    2009-06-10 14:45:00
  • oracle SQL解析步骤小结

    2009-09-30 10:46:00
  • CSS技巧之圆角背景与三角形

    2010-10-19 12:40:00
  • MySQL的root密码丢失解决方法

    2011-05-05 15:56:00
  • W3C web标准概念入门

    2008-05-25 15:06:00
  • JavaScript 获取客户端计算机硬件及系统信息

    2009-01-13 17:59:00
  • 基于关系型数据库引擎的\\XML\\索引技术

    2008-09-05 17:13:00
  • 在ASP中按指定参数格式化显示时间的函数。

    2010-05-27 12:29:00
  • 教程:mysql申明变量以及赋值

    2009-10-26 10:31:00
  • 大家一起来折磨浏览器吧!(好玩的东东)

    2010-02-07 12:40:00
  • ASP生成静态网页各种方法收集整理

    2008-02-18 19:25:00
  • img标签中alt和title属性的正确使用

    2008-01-10 12:59:00
  • 深底色页面设计指南[译]

    2009-08-06 18:16:00
  • Microsoft SQL Server 2008 正式发布

    2008-08-07 12:32:00
  • 一个导航的前端实现

    2008-11-13 12:41:00
  • 两个非常规ASP木马(可躲过扫描)

    2011-03-11 10:38:00
  • ASP-server.URLEncode反函数:urldecode

    2008-10-23 16:05:00
  • SQL和Oracle对数据库事务处理的差异性

    2009-10-14 09:43:00
  • asp之家 网络编程 m.aspxhome.com