欢迎光临
我们一直在努力

超长字符的智能分页-支持HTML

建站超值云服务器,限时71元/月

大概在九九年做游戏网站的时候,就对文章的发布感到麻烦,不过那会儿玩asp不精。只是将就用着。在遇到长文件 10000 字时网页就是一大片长了。

去年,做一个通用的文章与新闻管理系统时,曾写了一段代码,用来分离。现在贴出来。

要说明的是:

我的文章 录入界面是基于web的hemleditor,就像这里的abc代码差不多。所以实际提交的是html格式的文 本。

对html做了相应的处理,不会由html代码中切开。

这里另一位兄弟曾发表过一个,原理一样,不过我没仔细看过,不知有啥不同。

代码如下:

————————————–

request form item

i_forder = request.form ("i_folder")

i_topic = request.form ("i_topic")

i_title = htmlencode(request.form ("i_title"))

i_body = request.form ("body")

i_source = request.form ("i_source")

i_keyword= htmlencode(request.form ("i_keyword"))

i_ishot = request.form("ishot")

if i_ishot = "" then i_ishot="n"

i_ispic = request.form("ispic")

if i_ispic = "" then i_ispic ="n"

i_pic = request.form("insertimage")

i_body = replace(i_body,"contenteditable=true","contenteditable=false")

check input

……

get pages ,b = body

b_len = len(i_body)

b_pages = 1

t = temp

t_loop = true

do while t_loop 这里loop多次,每4000分一页,算出页码并加入库。

if b_len > 4000 then

n_body = left(i_body,4000) n = new

if "<p" in n_body,else ">" in n_body

if instrrev(n_body,"<p") > 0 and (len(n_body) – instrrev(n_body,"<p"))< 400 then

n_body = left(n_body,instrrev(n_body,"<p")-1)

else if instrrev(n_body,"  ") > 0 and (len(n_body) – instrrev(n_body,"  "))< 400 then

n_body = left(n_body,instrrev(n_body,"  ")-1)

else if instrrev(n_body,"。") > 0 and (len(n_body) – instrrev(n_body,"。"))< 400 then

n_body = left(n_body,instrrev(n_body,"。"))

else if instrrev(n_body,";") > 0 and (len(n_body) – instrrev(n_body,";"))< 400 then

n_body = left(n_body,instrrev(n_body,";"))

else if instrrev(n_body,",") > 0 and (len(n_body) – instrrev(n_body,","))< 400 then

n_body = left(n_body,instrrev(n_body,","))

else if instrrev(n_body,".") > 0 and (len(n_body) – instrrev(n_body,"."))< 400 then

n_body = left(n_body,instrrev(n_body,"."))

end if

end if

end if

end if

end if

end if

n_len = len(n_body)

i_body = mid(i_body,n_len+1)

b_len = len(i_body)

else

n_body = i_body

t_loop = false

end if

add to database

exec_prc_content_ins i_forder,i_topic,i_title,i_source,n_body,i_ispic,i_pic,i_ishot,i_keyword,b_pages

这里一个function,你可以自己处理,反正结果有两个,一个是body,一个是b_pages,就是页码。

b_pages = b_pages + 1

loop

%>

<html>

<head>

<meta name="generator" content="microsoft frontpage 5.0">

<meta name="progid" content="frontpage.editor.document">

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<title>新建网页 1</title>

<link rel="stylesheet" type="text/css" href="../css/default.css">

</head>

<body>

<div align="center">

<center>

<table border=1 width="300" height="128" bordercolor="#000000" cellspacing="0" cellpadding="0" style="border-collapse: collapse"><tr>

<td bgcolor="#dedbd6" height="31">

录入成功</td></tr><tr><td height="96">

<p align="center">此文章共分<%=b_pages-1%>页

</td></tr></table>

</center>

</div>

<script>

top.main_top.location.reload();

</script>

</body>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 超长字符的智能分页-支持HTML
分享到: 更多 (0)

相关推荐

  • 暂无文章