ASP內容分頁

2021-04-13 04:46:26 字數 1964 閱讀 6368

利用統計文章字數,然後達到一定字數就截斷輸出,但是分頁的內容就會在莫名其妙的地方截斷,不是很友好。

很簡單,在要截斷的地方附近找下面的符號:

;』」?。!;".!

如果後面存在或

就分頁。主要是要研究文章的格式。

<%

if request.servervariables("content_length") > 0 then

content = request.form("textarea1") 

pagelength = 1000 每頁字數

clength = len(content)

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)&"

"&j&":j"&seperator(j)&"

"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)&"

"&j&":j"&seperator(j)&"

"j = j + ubound(seperator) + 1 

end if

next

next

output = mid(content,1,pagearray(0))

output = replace(output,chr(13),"

")response.write "

第1段"

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),"

")response.write "

第"&i+1&"段

"response.write output

next

最後一段的輸出就沒寫了

else

%>

<%end if%> 

asp分頁系統

asp分頁系統 引數處理,並把相應 插入code 分頁 和mdbsql 資料庫查詢 中 sub s keyword s value keyword s value 建議先對keyword進行處理 if keyword then code code keyword keyword text split...

ASP 動態分頁

分頁和普通分頁是一樣的 主要就是如何 先橫向再縱向 排列的問題 這個問題在論壇討論了好多,你可以檢視頂貼,或者使用論壇的搜尋功能。function showpros tablename,topnum,fildname,loopnum,typenum set rs server.createobjec...

ASP分頁函式

asp分頁函式 function exportpageinfo byref rs,curpage,i,linkfile dim retval,j,pagenumber,basepage retval 第 curpage 頁 總 rs.pagecount 頁 retval retval 本頁 i 條 ...