<%
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
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, "'", "<'>")
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, "<'>", "'")
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>&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 & "<font color=""red"">[" & CStr(i) & "]</font>&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 & "</b></p>"
End If
Response.Write(ArticleContent)
End Function
%>

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

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

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

使用方法:

1.下载附件中的文件,将它解压上传到您的网站根目录

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

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

转载于:https://www.cnblogs.com/y0umer/archive/2009/09/27/3839438.html

ASP长文章内容自动分页函数相关推荐

  1. asp.net中长内容自动分页的实现

    在一篇文章过长时,可以自动的写个小程序对其进行分页. 具体代码: public class t3 : System.Web.UI.Page        {                   pri ...

  2. 方便快捷的php长文章分页函数,PHP长文章分页的一种实现方法

    PHP长文章分页的一种实现方法[登录] 因项目需要,需要用PHP写一个长文章的分页函数,还是老方法,先看网上有没有现成的,于是找到了被众多网站引用的一个长文章分页的PHP函数,我主要参考了<方便 ...

  3. ASP用替换函数给文章内容所有图片加上alt属性内容

    ASP如何用替换函数给文章内容所有图片加上alt属性内容? 首先您得获取得到content内容,然后利用替换函数,把所有的图片标签找出来,然后根据规则替换里面Alt属性内容 content=repla ...

  4. 使用PHP将长文章分页

    新学的同志们,今天给大家们说一个很好的分页方法,值需要简单的几行代码和一个封装好的类就可以轻松的完成长文章进行分页的方法,再也不用每次敲那繁琐的代码,我希望今天给的代码可以对大家能够有用. 好了,废了 ...

  5. wordpress 文章php,wordpress怎么发长文章

    有时单个文章页面篇幅过长,会影响页面加载速度和用户体验,这时我们需要使用WordPress长文章分页显示.实现分页有二种方法,一种是使用wordpress长文章分页插件,另一种是通过修改代码来实现. ...

  6. 博客文章内容导航(实时更新)

    博客文章内容导航(实时更新)   大家好,我是亓官劼(qí guān jié),在博客中分享数据结构与算法.Python全栈开发.Java后端开发.前端.OJ题解及各类报错信息解决方案等经验.一起加油 ...

  7. 分享106个ASP新闻文章源码,总有一款适合您

    分享106个ASP新闻文章源码,总有一款适合您 106个ASP新闻文章源码下载链接:https://pan.baidu.com/s/143-M0-nwEaUNwGyfFV4Hjw?pwd=af8r  ...

  8. 分页插件php,文章内容分页插件

    应用信息 名称: 文章内容分页插件 售价: 128元 应用ID: NextPage 最低要求: Z-BlogPHP 1.5.2.1935 (Zero) Build 151935 版 本: 6.1 发布 ...

  9. 正则表达式 html链接,ASP超级链接和HTML函数正则表达式 修正版

    过滤超级链接 Function RegRemoveHref(HTMLstr) Set ra = New RegExp ra.IgnoreCase = True ra.Global = True ra. ...

最新文章

  1. TCP层,flags字段标识位含义说明
  2. 励志:读书七年,为了挣钱,我竭尽全力
  3. Live Messenger 邀请,再次放送
  4. 从客户端(Content=EM STRONG U 这是测试这...)中检测到有潜在危险的Request.Form 值。...
  5. java 超构造函数_java中的超级构造函数
  6. sed高级命令及模式空间和交换空间简介
  7. 【Vue2.0】— 插件(十六)
  8. [置顶] Android玄铁剑之TextView之图文并茂
  9. Android Framework 全面分析 BootAnimation
  10. 理解图像中的低频分量和高频分量
  11. 微信运营:必须收藏的101条万能微信标题公式
  12. 特洛伊木马 (计算机木马程序)
  13. 概率论基础 - 6 - 切比雪夫不等式
  14. uncode ansi详解
  15. 时间复杂度和空间复杂度
  16. 前端切图实战(PSD设计稿转化为前端)
  17. ubuntu 下浏览器中打开网页乱码解决
  18. linux rewind函数,fseek(),ftell()和rewind()函数的用法详解
  19. 数字图像处理(第二章)
  20. Unity跑酷游戏中的路点生成算法

热门文章

  1. ASP.NET Core【在线教育系统】功能要求
  2. spotlight soo5072:there was an error reading the tnsnames.ora
  3. MacOS安装react。问题 -- npm全局包的权限问题
  4. day_work_02
  5. web端 复合控件 响应回发
  6. 软件工程进度条-第十二周
  7. C#sql语句如何使用占位符
  8. IplImage类型解释和举例
  9. 公用表表达式(CTE)WITH:树型查询、更新
  10. python的类变量和成员变量用法_Python面向对象程序设计类变量与成员变量、类方法与成员方法用法分析...