ASP长文章分页代码实例
来源:asp之家 时间:2007-10-02 17:04:00
ASP长文章分页代码实例,也许你会问一篇文章为什么还要进行分页呢?因为文章有短有长,当你的文章很长的时候,如果就一个页面都显示出来的话,读者一看文章这么长,他很可能放弃阅读,他会想这么长我要读到什么时候啊!而且密码麻麻的很容易吓到读者,呵呵!如果你给他分页了,比如1000个文字左右分了一页的话,给读者的心里感觉就不同了,他会不知不觉的阅读下去。
这里使用了文章分页标志:{nextpage}来进行长文章分页,当然你也可以换成其它你喜欢的标志符号,但是一定要注意你的分页标志不能太普通,否则在文章中一旦出现这个标志就会分一页了。
下面我说一下使用分页标志来进行长文章分页的原理,其实分页的原理也很简单,从数据库中读取含有分页标志的文章内容后(当然文章短的话就不用加分页标志了),利用asp的split函数把文章内容存入数组。显示的时候,就按顺序读取数组内容就可以了。
下面的程序基本可以满足动态页面的长文章分页使用了,程序来源网络。
<%
Class aspxsky_page
Private Sub class_initialize
End Sub
Public Function Alert(message,gourl)
message = replace(message,"’","\’")
If gourl="-1" then
Response.Write ("<script language=javascript>alert(’" & message & "’);history.go(-1)</script>")
Else
Response.Write ("<script language=javascript>alert(’" & message & "’);location=’" & gourl &"’</script>")
End If
Response.End()
End Function
Public Sub showpage(str,page,url)
if not isnumeric(page) then
alert "提示:错误的参数!","-1"
end if
if page="" or page=0 or isnull(page) or isempty(page) then
page=1
else
page=cint(page)
end if
str=split(str,"{nextpage}")
abspage=page
pcount=ubound(str)+1
if page>cint(ubound(str)+1) or page<1 then
alert "提示:错误的参数!","-1"
else
response.write str(page-1)&"<br><br><center> 共分为"&pcount&"页 "
end if
for p=0 to ubound(str)
response.write "<a href="&url&"p="&p+1&">["&p+1&"]</a> "
next
response.write "当前第"&abspage&"/"&pcount&"页</center>"
End Sub
End Class
调用方法:这里的str就是文章的内容,在实际使用时换成你文章的内容就可以了。p是页码
p=request.QueryString("p")
str="第一页:这里是第一页的内容{nextpage}第二页:这里是第二页的内容"
url="shownews.asp?id="&id&"&"
set newpage=new aspxsky_page
newpage.showpage str,p,url
当然知道了这个长文章分页的原理后,你完全可以自己试着写个程序,应该不会难的。
标签:分页,长文章
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python搭建APNS苹果推送通知推送服务的相关模块使用指南
2021-09-27 22:12:59
Python模块WSGI使用详解
2021-02-19 00:05:27
python使用pyodbc连接sqlserver
2021-12-24 06:06:17
![](https://img.aspxhome.com/file/2023/1/69031_0s.png)
Linux下编译安装python3步骤
2021-11-07 17:50:04
![](https://img.aspxhome.com/file/2023/2/124582_0s.png)
python图片指定区域替换img.paste函数的使用
2023-10-17 02:34:01
![](https://img.aspxhome.com/file/2023/3/131303_0s.jpg)
ie8下ewebeditor无效的解决办法
2010-02-28 10:31:00
PHP封装的数据库模型Model类完整示例【基于PDO】
2023-11-15 21:06:42
javascript事件冒泡,事件捕获和事件委托详解
2024-04-10 14:02:47
Python 获取主机ip与hostname的方法
2021-05-13 09:30:30
python 使用cx-freeze打包程序的实现
2022-10-18 12:23:26
![](https://img.aspxhome.com/file/2023/1/124781_0s.jpg)
两个不太常用的 CSS Hack
2008-06-27 12:49:00
ubuntu 安装pyqt5和卸载pyQt5的方法
2021-08-25 07:18:41
python SOCKET编程基础入门
2021-04-20 17:22:33
![](https://img.aspxhome.com/file/2023/6/87466_0s.jpg)
python中DataFrame数据合并merge()和concat()方法详解
2022-05-23 15:00:16
![](https://img.aspxhome.com/file/2023/0/102970_0s.png)
Python3+selenium配置常见报错解决方案
2022-12-21 14:44:53
关于CSS中字号控制的兼容性研究
2010-01-23 12:48:00
丢失的数据忘记备份的处理方法[图文]第1/2页
2024-01-18 22:18:41
![](https://img.aspxhome.com/file/2023/9/92749_0s.jpg)
python 命名规范知识点汇总
2023-04-23 16:03:38
python实现excel转置问题详解
2023-06-27 23:27:27
![](https://img.aspxhome.com/file/2023/7/93627_0s.png)
Vue实现通知或详情类弹窗
2024-05-29 22:45:06
![](https://img.aspxhome.com/file/2023/3/123033_0s.jpg)