您好,欢迎来到点滴吧! 手机版
点滴吧www.diandiba.com
记录点点滴滴,尽在点滴吧
  • 文章
  • 文章
  • 特效
  • 素材
  • 景点
您现在的位置:首页 > ASP教程 > 文章正文
ASP实现超长文章内容因太长自动分页或手动分页
更新时间:2015/1/5 16:49:10   点击:2361次

’按标识手动分页 

function manualpage(str) 
pages=request.querystring("page") 
contentstr=split(str,"{$page$}") 
response.write(contentstr(pages)) 
response.write("<p/>") 
response.write("<div class=""pagelist"">") 
for i = 0 to ubound(contentstr)  
response.write("<a href=’?id="&id&"&page="&i&"’>"&i+1&"</a>&nbsp;") 
next 
response.write("</div>") 
end function

’按长度分页 

function autopage(str,fontnum) 
if len(str)>fontnum then 
if len(str) mod fontnum>0 then ’计算总页数 
pagecontent=len(str)\fontnum+1 
else 
pagecontent=len(str)\fontnum 
end if 
dim arr() 
redim arr(pagecontent) 
for m = 1 to pagecontent 
if m<>pagecontent then 
arr(m)= mid(str,(m*fontnum-fontnum+1),fontnum) 
else 
arr(m)= mid(str,(m*fontnum-fontnum+1),len(str)) 
end if 
next 
if request.querystring("page")<>"" then 
response.write(arr(request.querystring("page"))) 
else 
response.write(arr(1)) 
end if 
response.write("<p/>") 
response.write("<div class=""pagelist"">") 
for i = 1 to pagecontent 
response.write("<a href=?id="&id&"&page="&i&">"&i&"</a> ") 
next 
response.write("</div>") 
else 
response.write(str) 
end if 
end function

在页面中:

<%  
if instr(content,"{$page$}")=0 then ’判断是否是手工分页标志,不是就自动分页 
call autopage(content,2000) 
else 
call manualpage(content) 
end if 
%>


上一篇:ASP读取Excel   下一篇:ASP获取字符串长度
相关文章
导航分类
热门文章
关于我们| 联系我们| 免责声明| 网站地图|
CopyRight 2012-2015 www.diandiba.com - 点滴吧 All Rights Reserved
滇ICP备09005765号-2