长文章自动分页asp实例-支持HTML

来源:动网 时间:2007-10-10 21:29:00 

大概在九九年做游戏网站的时候,就对文章的发布感到麻烦,不过那会儿玩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>长文章自动分页asp实例-支持HTML - asp之家</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
投稿

猜你喜欢

  • 使用php语句将数据库*.sql文件导入数据库

    2023-11-23 05:11:22
  • Spring Boot集成MyBatis访问数据库的方法

    2024-01-23 06:45:43
  • 详解Vue3如何加载动态菜单

    2024-04-27 15:56:52
  • Python中使用pprint函数进行格式化输出的教程

    2022-08-26 03:34:17
  • Django logging配置及使用详解

    2022-06-01 14:12:48
  • Python中安装easy_install的方法

    2022-06-22 20:30:00
  • 知识蒸馏联邦学习的个性化技术综述

    2022-07-04 21:03:51
  • 理解JavaScript作用域链

    2010-01-23 11:31:00
  • 谈谈XHTML中CDATA

    2007-09-17 12:45:00
  • Python制作一个多功能音乐播放器

    2022-06-15 10:16:05
  • Python3 Loguru输出日志工具的使用

    2021-11-18 04:28:29
  • Python面向对象程序设计之类的定义与继承简单示例

    2022-03-24 03:00:16
  • php实现的三个常用加密解密功能函数示例

    2023-07-20 06:25:52
  • Django框架的中的setting.py文件说明详解

    2022-11-05 13:26:24
  • python通过opencv实现批量剪切图片

    2021-05-12 12:50:14
  • 基于mysql乐观锁实现秒杀的示例代码

    2024-01-18 02:01:41
  • Node.js Koa2使用JWT进行鉴权的方法示例

    2024-05-02 17:05:45
  • python3实现高效的端口扫描

    2023-07-23 12:18:06
  • Tensorflow2.10实现图像分割任务示例详解

    2021-08-31 13:14:47
  • Python实现合并excel表格的方法分析

    2022-04-24 21:30:22
  • asp之家 网络编程 m.aspxhome.com