长文章生成静态文件自动分页问题
来源:
互联网
日期:2006-5-15
数据库有个字段是备注型,里面存储的是一篇文章,如果文章太长的话,很不好读,能不能做成这样的:http://www.asiagame.com/glmj/show_guide_cn.asp?guide_sn=20031244235 让文章分页,这样做好很多,有没有人做过类似的,如何实现? 自己做了个简单分页的,但效果不好,碰到有图片代码的地方就会把图片代码分成在两个不同的页面!!!! --------------------------------------------------------------- <% if Request.ServerVariables("Content_Length") > 0 then content = Request.Form("textarea1") PageLength = 1000 '每页字数 CLength = Len(content) if CLength>=PageLength then PageCount = Int(Clength/PageLength) + 1 '计算页数 dim PageArray redim PageArray(PageCount) Seperator = Array(chr(13),chr(10),"。","!","?",";",",","”","’") '分隔符 PageArray(0) = 0 Pos = 0 for j=0 to ubound(Seperator) Pos = instr(PageArray(i)+900,content,Seperator(j)) 'PageArray(i)+900 附近位置是100字,1-999可调 while Pos > 0 and Pos < (i+1)*PageLength and Pos > i*PageLength PageArray(i) = Pos Pos = instr(Pos+PageLength,content,Seperator(j)) wend if PageArray(i) > 0 then 'Response.Write "0:i¦ "&PageArray(i)&"<br>"&j&":j"&Seperator(j)&"<br>" j = j + ubound(Seperator) + 1 end if next for i=1 to PageCount-1 PageArray(i) = 0 Pos = 0 for j=0 to ubound(Seperator) Pos = instr(PageArray(i-1)+950,content,Seperator(j)) while Pos > 0 and Pos < (i+1)*PageLength and Pos > i*PageLength PageArray(i) = Pos Pos = instr(Pos+PageLength,content,Seperator(j)) wend if PageArray(i) > 0 then 'Response.Write i&":i¦ "&PageArray(i)&"<br>"&j&":j"&Seperator(j)&"<br>" j = j + ubound(Seperator) + 1 end if next next output = mid(content,1,PageArray(0)) output = replace(output,chr(13),"<br>") response.Write "共" & PageCount & "段" Response.Write "<br><br>第1段<br><hr>" Response.Write output for i=1 to PageCount-2 output = mid(content,PageArray(i-1)+1,PageArray(i)-PageArray(i-1)) output = replace(output,chr(13),"<br>") Response.Write "<br><br>第"&i+1&"段<br><hr>" Response.Write output next'最后一段的输出就没写了 else response.Write Content end if else %> <FORM action="" method=POST id=form1 name=form1> <TEXTAREA rows=20 cols=130 id=textarea1 name=textarea1> </TEXTAREA><br> <INPUT type="submit" value="Submit" id=submit1 name=submit1> </FORM> <%end if%>
更多的长文章生成静态文件自动分页问题请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2006-5-15
|
|
|