大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> 对一篇很长的文章做到完美的分页输出(转)

对一篇很长的文章做到完美的分页输出(转)

时间: 2021-07-31 作者:daque

运用统计作品篇幅,而后到达确定篇幅就截断输入,然而分页的实质就会在莫明其妙的场合截断,不是很和睦。很大略,在要截断的场合邻近找底下的标记:;’”?。!;'".!即使反面生存<p>或<br>就分页。主假如要接洽作品的方法。<%if request.servervariables("content_length") > 0 thencontent = request.form("textarea1")pagelength = 1000'每页篇幅clength = len(content)pagecount = int(clength/pagelength) + 1'计划页数dim pagearrayredim pagearray(pagecount)seperator = array(chr(13),chr(10),"。","!","?",";",",","”","’")'分割符pagearray(0) = 0pos = 0for 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*pagelengthpagearray(i) = pospos = instr(pos+pagelength,content,seperator(j))wendif pagearray(i) > 0 then response.write "0:i¦ "&pagearray(i)&"<br>"&j&":j"&seperator(j)&"<br>"j = j + ubound(seperator) + 1 end ifnextfor i=1 to pagecount-1pagearray(i) = 0pos = 0for 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*pagelengthpagearray(i) = pospos = instr(pos+pagelength,content,seperator(j))wendif pagearray(i) > 0 then response.write i&":i¦ "&pagearray(i)&"<br>"&j&":j"&seperator(j)&"<br>"j = j + ubound(seperator) + 1 end ifnextnextoutput = mid(content,1,pagearray(0))output = replace(output,chr(13),"<br>")response.write "<br><br>第1段<br>"response.write outputfor i=1 to pagecount-2output = mid(content,pagearray(i-1)+1,pagearray(i)-pagearray(i-1))output = replace(output,chr(13),"<br>")response.write "<br><br>第"&i+1&"段<br>"response.write outputnext'结果一段的输入就没写了else%><form action="" method=post id=form1 name=form1><textarea rows=70 cols=120 id=textarea1 name=textarea1></textarea><input type="submit" value="submit" id=submit1 name=submit1></form><%end if%>

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.