欢迎访问雨楠喃语官方个人主页!
咨询电话:139-9180-9967
正在浏览:[原创]新闻或文章内容手动分页代码(含自定义参数)
[ASP][原创]新闻或文章内容手动分页代码(含自定义参数)
作者:互联网 | 来源:网络 | 发布:2011/1/6 14:47:58 | 浏览:8959

首先是CSS的基本定义:

<style>
ul,li{display:inline;}
#zzPage{margin:auto;background:#fff;}
#zzPage ul{}
#zzPage ul li{color:#ffffff;font-size:12px;text-align:center;padding:5px;margin:1px;background:#000000;}
#zzPage ul li a{color:#ffffff;font-size:12px;text-decoration: none;}
#zzPage ul li a:link {color:#ffffff;font-size:12px;text-decoration: none;}
#zzPage ul li a:hover{color:#FF0000;font-size:12px;text-decoration:underline;}
</style>

[yunanpage]

函数代码:

<%
'=================================================
'过程名:AutoPage
'作 用:手动分页
'参 数:str,stype
'参数说明:str(要分页的内容),stype(分页码),surl(当前地址)
'=================================================
sub AutoPage(str,stype,surl)
'要分页的内容
Dim strCont,ContLen
strCont = str       '获取内容
ContLen=len(strCont)     '获取长度
Dim aPage,arrCont,nPage
nPage=trim(request("p"))

if Instr(strCont,stype)<=0 then
 response.write strCont    '如果没有分页符,直接输出内容
else
 arrCont=split(strCont,stype)  '根据分页符获取数组
 aPage=Ubound(arrCont)+1    '获取总页数
  if nPage = "" Then nPage=1
  If nPage <>"" Then nPage=Int(nPage)
  if nPage < 1  Then nPage=1
  if nPage > aPage then nPage=aPage
 response.write arrCont(Int(nPage)-1) '输入当前数组的内容
'........页码开始输出.......
response.write "<br /><p align='center'>"
response.write "<div id=""zzPage"">"
response.write "<ul>"
If nPage = 1 Then
response.write "<li><a href='"&surl&"?p="&nPage&"'>上一页</a></li>"
Else
response.write "<li><a href='"&surl&"?p="&nPage-1&"'>上一页</a></li>"
End If
for i=1 to aPage
 if i = nPage then
  response.write "<li><font color='red'>" & nPage & "</font></li>"
 else
  response.write "<li><a href='"&surl&"?p="&i&"'>" & i & "</a></li>"
 end if
Next
If nPage = aPage Then
response.write "<li><a href='"&surl&"?p="&nPage&"'>下一页</a></li>"
Else
response.write "<li><a href='"&surl&"?p="&nPage+1&"'>下一页</a></li>"
End If

response.write "</ul>"
response.write "</div></p>"
'........页码结束输出.......
end If
end sub
%>

[yunanpage]

使用方法:

<%Call AutoPage(内容,"分页符","地址")%>

相关ASP