实现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(您以前的内容显示变量)%>。
猜你喜欢
- 问题当浏览SQL Server 2008的新特性时,我们看到了透明数据加密。这看起来很有趣。您能为我们解释一下并介绍下执行它的细节吗?专家解
- 对于经常使用MYSQL的人来说,phpmyadmin是一个必备的工具。这个工具非常强大,几乎可以完成所有的数据库操作,但是它也有一个弱点,对
- 关于ajax的responseText乱码的问题这个问题让我和纠结百度了好多都说是javascript的编码问题但是我的 javascrip
- 一. 输出函数print在python中,print()是可以直接使用的输出函数,将数据输出到控制台上。1. print函数的使用1.1 可
- 贪食蛇是一个非常经典的游戏, 在游戏中, 玩家操控一条细长的直线(俗称蛇或虫), 它会不停前进, 玩家只能操控蛇的头部朝向(上下左右), 一
- Access 操作很简单,具体不步骤如下:打开你mdb数据库,工具-->数据库实用工具-->压缩和修复数据库(c)... SQL SERVE
- 利用Python中的socket模块中的来实现UDP协议,这里写一个简单的服务器和客户端。为了说明网络编程中UDP的应用,这里就不写图形化了
- 微博热搜的爬取较为简单,我只是用了lxml和requests两个库url= https://s.weibo.com/top/summary?
- 在项目开发的过程中,经常会遇到要查看图像细节的问题,这时候我们通常会,滚动滑轮将图像放大,或者使用电脑内置的放大器功能进行查看,如下图所示,
- 使用fillna()填充缺失值df = pd.read_csv('ccf_offline_stage1_train.csv'
- 前言大家好!这个系列文章是W3CN 阿捷编写的。是一些制作过程中的心得和经验,希望对大家有点帮助。第一天开始制作符合标准的站点,第一件事情就
- Python 编程语言已经成为 IT 中使用的最流行的语言之一。成功的一个原因是它可以用来解决各种问题。从网站开发到数据科学、机器学习到任务
- 一、基本使用最近研究了一下 el-upload组件 踩了一些小坑 写起来大家学习一下很经常的一件事情 经常会去直接拷贝 elem
- 第一种:ROW_NUMBER() OVER()方式select * from ( select *, ROW_NUMBER() OVER(O
- 双向RNN:bidirectional_dynamic_rnn()函数的使用详解先说下为什么要使用到双向RNN,在读一篇文章的时候,上文提到
- 程序是从上到下顺序执行的,同时可以通过一些控制语句来改变执行的路线,受控制语句影响下,程序最终的执行路线就是控制流。js 里面的控制语句有
- python3.7简单的爬虫,具体代码如下所示:#https://www.runoob.com/w3cnote/python-spider-
- 如果你需要一个PDF文件合并工具,那么本文章完全可以满足您的要求。哈喽,大家好呀,这里是滑稽研究所。不多废话,本期我们利用Python合
- 学习python过程中想使用python的matlabplot绘图功能,遇到了一大批问题,然后一路过关斩将,最终安装成功,实为不易,发帖留念
- 最近在无忧脚本混了一阵子,回复了一些贴子,自己却没有做出什么东东让大家看看,心里有些不安,于是写了下边的一点东西,本来应该发在类封装区的,考