数据库有个字段是备注型,里面存储的是一篇文章,如果文章太长的话,很不好读,能不能做成这样的:http://www.asiagame.com/glmj/show_guide_cn.asp?guide_sn=20031244235
让文章分页,这样做好很多,有没有人做过类似的,如何实现?
自己做了个简单分页的,但效果不好,碰到有图片代码的地方就会把图片代码分成在两个不同的页面!!!!
---------------------------------------------------------------
1
2if Request.ServerVariables("Content_Length") > 0 then
3content = Request.Form("textarea1")
4PageLength = 1000 '每页字数
5CLength = Len(content)
6if CLength>=PageLength then
7PageCount = Int(Clength/PageLength) + 1 '计算页数
8dim PageArray
9redim PageArray(PageCount)
10Seperator = Array(chr(13),chr(10),"。","!","?",";",",","”","’") '分隔符
11PageArray(0) = 0
12Pos = 0
13for j=0 to ubound(Seperator)
14Pos = instr(PageArray(i)+900,content,Seperator(j)) 'PageArray(i)+900 附近位置是100字,1-999可调
15while Pos > 0 and Pos < (i+1)*PageLength and Pos > i*PageLength
16PageArray(i) = Pos
17Pos = instr(Pos+PageLength,content,Seperator(j))
18wend
19if PageArray(i) > 0 then
20'Response.Write "0:i¦ "&PageArray(i)&"
<br/>
1"&j&":j"&Seperator(j)&"
<br/>
1"
2j = j + ubound(Seperator) + 1
3end if
4next
5for i=1 to PageCount-1
6PageArray(i) = 0
7Pos = 0
8for j=0 to ubound(Seperator)
9Pos = instr(PageArray(i-1)+950,content,Seperator(j))
10while Pos > 0 and Pos < (i+1)*PageLength and Pos > i*PageLength
11PageArray(i) = Pos
12Pos = instr(Pos+PageLength,content,Seperator(j))
13wend
14if PageArray(i) > 0 then
15'Response.Write i&":i¦ "&PageArray(i)&"
<br/>
1"&j&":j"&Seperator(j)&"
<br/>
1"
2j = j + ubound(Seperator) + 1
3end if
4next
5next
6output = mid(content,1,PageArray(0))
7output = replace(output,chr(13),"
<br/>
1")
2response.Write "共" & PageCount & "段"
3Response.Write "
<br/>
<br/>
1第1段
<br/>
<hr/>
1"
2Response.Write output
3for i=1 to PageCount-2
4output = mid(content,PageArray(i-1)+1,PageArray(i)-PageArray(i-1))
5output = replace(output,chr(13),"
<br/>
1")
2Response.Write "
<br/>
<br/>
1第"&i+1&"段
<br/>
<hr/>
1"
2Response.Write output
3next'最后一段的输出就没写了
4else
5response.Write Content
6end if
7else
1<form action="" id="form1" method="POST" name="form1">
2<textarea cols="130" id="textarea1" name="textarea1" rows="20">
3</textarea><br/>
4<input id="submit1" name="submit1" type="submit" value="Submit"/>
5</form>
1end if