对长了的文章进行分页显示!
2006-03-25 07:45
447 查看
介绍以下函数的用法,一般,如显示新闻内容的ASP文件都要至少收集id 的值,如果你的最终显示的新闻串的值为 s 的话 调用方法就是: <%=kellyPage(s)%> 演示地址: http://www.w2000.com.cn/sweet/doc/show.asp?id=404 此函数功能:显示长文章的页数并显示出当前页的新闻 注:这个函数一看就知道是在服务器端运行的,难免会有效率问题,如果你的服务器不太好的话,可以把这个函数放在客户端处理。。。。 <%Function kellyPage(Str) Str=Replace(Server.Htmlencode(Str),Chr(13),"<br>") Dim p,i,arr,returns,show,tolp,star,endstar Const countbr=20 '每页显示的行数 If Request.QueryString("docp")="" Then p=1 Else p=Cint(Request.QueryString("docp")) If p<1 Then p=1 End If arr=Split(Str,"<br>") returns="" For i=(p-1)*countbr To p*countbr If i>Ubound(arr) Then Exit For returns=returns&arr(i)&"<BR>" Next returns=returns&"<br><br><br><br>" If p>1 Then returns=returns&"<a href="""&Request.ServerVariables("URL")&"?id="&Request.QueryString("id")&"&docp="&(Cint(p)-1)&""">上一页</a> " End If If Ubound(arr) Mod countbr<>0 Then tolp=Ubound(arr)\countbr+1 Else tolp=Ubound(arr)\countbr End If Set arr=Nothing star=1:endstar=1 If p>5 Then star=Cint(p)-5 If Cint(star)<>1 Then returns=returns&".. " End If If Cint(star)+9>tolp Then endstar=tolp Else endstar=Cint(star)+9 End If For i=star To endstar %> <% If i=Cint(p) Then returns=returns&"[<b><font color=red>"&i&"</font></b>] " Else returns=returns&"[<a href="""&Request.ServerVariables("URL")&"?id="&Request.QueryString("id")&"&docp="&i&""">"&i&"</a>] " End If Next If endstar<tolp Then returns=returns&".. " If p<tolp Then returns=returns&"<a href="""&Request.ServerVariables("URL")&"?id="&Request.QueryString("id")&"&docp="&(Cint(p)+1)&""">下一页</a>" End If kellyPage=returns End Function%> var aspCode_resultScript = function() { function getTitle(text) { text = String(text); text = text.replace(/ /gi , "\t"); text = text.replace(/ /gi , " "); text = text.replace(/&/gi , "&"); text = text.replace(/"/gi , "\""); text = text.replace(/</gi , "<"); text = text.replace(/>/gi , ">"); text = text.replace(/ /gi , "\n"); text = text.replace(/<\/?font[^>]*>/gi , ""); return text.substring(0,600) + (text.length > 600 ? "......" : ""); } var _asp = []; for (var i = 0 ; 1 == 1 ; i++) { var op1 = document.getElementById("aspCode_ex_" + i); if (! op1) break; op1.onselectstart = function() { return false; } op1.onclick = function() { var idx = this.id.replace(/[^\d]/g , ""); var op2 = document.getElementById("asp" + idx); if (this.ex == "+") { _asp[idx] = op2.innerHTML; this.ex = "-"; this.title = "展开"; op2.innerHTML = " [ASP代码块] 双击展开 "; op2.ondblclick = function() { document.getElementById("aspCode_ex_" + idx).onclick(); } op2.title = getTitle(_asp[idx]); } else { this.ex = "+" this.title = "收起"; op2.innerHTML = _asp[idx]; op2.ondblclick = function() { ; } op2.title = ""; } } //op1.onclick(); } };aspCode_resultScript(); |
相关文章推荐
- 比较长的文章进行分页显示
- 文章,记录按内容分页显示,根据文章内容按字数进行分页
- 文章,记录按内容分页显示,根据文章内容按字数进行分页
- 文章,记录按内容分页显示,根据文章内容按字数进行分页(转)
- 文章,记录按内容分页显示,根据文章内容按字数进行分页
- 文章,记录按内容分页显示,根据文章内容按字数进行分页
- 长文章中插入分页符^进行分页
- 【C#】文章正文显示和文章列表分页,审核功能的添加
- ECShop新建页面并进行分页显示
- php分页显示文章列表
- thinkphp中对数组元素进行分页显示
- 织梦文章内容页面分页显示数量控制…
- 分页(对查询出的数据进行分页显示)
- 对html或jsp文章列表页面进行js分页,结合使用apache的url Rewrite和jquery
- 一个ASP.NET长文章分页显示函数
- 长文章用分页符来分页显示
- web学习之博客小项目(分页显示文章)
- 用jsp进行数据分页显示的一个实现
- php文章页码的分页显示 函数 类似于Google搜索下面的分页
- 文章太长?分页显示!