ASP实现长文章自动分页的函数代码
来源:天极 发布时间:2008-10-10 17:09:00
以下是引用片段:
Function c2u(myText)
Dim i
c2u = ""
For i = 1 to Len(myText)
c2u = c2u & "&#x" & Hex(AscW(Mid(myText, i, 1))) & ";"
Next
End Function
以下是引用片段:
Function cutStr(str,strlen)
'去掉所有HTML标记
Dim re
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="<(.[^>]*)>"
str=re.Replace(str,"")
set re=Nothing
Dim l,t,c,i
l=Len(str)
t=0
For i=1 to l
c=Abs(Asc(Mid(str,i,1)))
If c>255 Then
t=t+2
Else
t=t+1
End If
If t>=strlen Then
cutStr=left(str,i)&"..."
Exit For
Else
cutStr=str
End If
Next
cutStr=Replace(cutStr,chr(10),"")
cutStr=Replace(cutStr,chr(13),"")
End Function
以下是引用片段:
Function converttowide(str)
Dim strlen
Dim position
Dim convertstr
if isnull(str) then
converttowide=str
else
position=1
strlen=Len(str)
For i=1 To strlen
convertstr=convertstr+"&#x"+Hex(AscW(Mid(str,position,1)))+";"
position=position+1
Next
converttowide=convertstr
end if
End Function
以下是引用片段:
dim topicx,usernamex,addtimex,logtextx,ispassword
'获取ID号
articleid=request("articleid")
'写执行语句
strSQL = "select * from article where articleid="&articleid&""
'接上面函数
logtextx=cutStr(rs("content"),5000)
'开始分页
dim page,PageLength,CLength,PageCount,wen,a
if Request("Page")<>"" then Page = CLng(Request("Page"))
PageLength = 80
CLength = Len(logtextx)
PageCount = Int(Clength/PageLength) + 1
if Page < 1 or IsNull(Page) Then Page = 1
if Page > PageCount Then Page = PageCount
if page=1 then
a=1
elseif page>1 then
a=(Page-1)*PageLength
end if
wen=Mid(logtextx,a,PageLength)
'判断
if page="" or page=1 then
'开始显示内容
Response.write (c2u("内容:"))'www.w3sky.com
end if
Response.write (converttowide(wen))
Response.write "<br/>"
'Response.write (converttowide("本文字数:")) & CLength &"<br/>"
Response.write (c2u("本文被分为")) & PageCount & (converttowide("页"))&" "&c2u("当前为"&Page&"页")&"< br/>"
if PageCount >1 and page <> 1 then'www.w3sky.com
Response.write "1 "
end if
dim j
For j=Page+1 To Page+10
if j <= PageCount-1 then
Response.write ""&j&" "
end if
next
if PageCount >1 and Page <> PageCount then
Response.write "<a href="/"showarticle.asp?articleid="&articleid&"&Page="&PageCount&""">"&PageCount&"</a><br/>"
End if
'结束
以上代码在WIN2000+IIS5、WIN2003+IIS6 上执行通过
猜你喜欢
- 首先,Python 标准库中的 urllib2 模块提供了你所需要的大多数 HTTP 功能,但是它的 API 不友好。它是为另一个时代、另一
- 如果你的PHP网站换了空间,必定要对Mysql数据库进行转移,一般的转移的方法,是备份再还原,有点繁琐,而且由于数据库版本的不一样会导致数据
- 这个函数的使用方法,已经有前辈讲解过了,只是自己在测试的时候有一些思考,所以便写了这篇博客。下面是前辈文章的原话:seed( ) 用于指定随
- 介绍:UUID是128位的全局唯一标识符,通常由32字节的字符串表示。使用:import uuid print uuid.uuid1()14
- 本文实例分析了AJAX使用get与post模式的区别。分享给大家供大家参考。具体分析如下:如果是get 模式的请求,则将传递参数通过URL
- 程序中经常需要使用excel文件,批量读取文件中的数据python读取excel文件可以使用xlrd模块pip install xlrd安装
- 项目我采用了三层结构,我把LINQ的映射文件放到了DAL这个层中,映射文件自动由VS2008生成,在原来的机器上一直正常,一点问题都没有,当
- 一、关系型数据库设计规则遵循ER模型和三范式E entity 代表实体的意思 对应到数据库当中的一张表R relationship 代表关系
- 我们在使用pycharm的时候总是很喜欢其强大的代码提示功能,只需ctrl+左键就可以查看源码,"."也能显示所含的函数
- 本文实例讲述了JS简单获取并修改input文本框内容的方法。分享给大家供大家参考,具体如下:一 介绍获取文本框并修改其内容可以使用getEl
- 下面是滚动条css代码参数介绍:scrollbar-3d-light-color 设置或检索滚动条亮边框颜色 scrollbar-highl
- 平时自己写了很多代码,但从没好好计算总共写了多少行,面试时被问起来,就傻了。。。闲来无事,写个python程序来统计下import os##
- Spark Streaming VS Structured StreamingSpark Streaming是Spark最初的流处理框架,使
- 本文实例讲述了Python框架Flask的基本数据库操作方法。分享给大家供大家参考,具体如下:数据库操作在web开发中扮演着一个很重要的角色
- 本文实例为大家分享了python实现简单贪吃蛇的具体代码,供大家参考,具体内容如下1. 导入游戏库import pgzrunimport r
- 这篇文章主要介绍了python实现括号匹配方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可
- function siblings(o){//参数o就是想取谁的兄弟节点,就把那个元素传进去 var a=[];//定义一个数组,用来存o的
- 介绍这个例子主要利用turtle库实现根据输入动态展示不同机器人的图像和属性信息。代码部分非原创只是做了些许修改和整理使得更易阅读。图片和文
- 前言……最近在学习yolo1、yolo2和yolo3,写这篇博客主要是为了让自己对yolo2的结
- 插件下载:blueideasearch.xpi首先第一步 说一下怎么样查看firefox插件的源码, 就我上边写的那个东西,把它下载下来.将