蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

(求助)我做新闻系统时遇到问题...新闻详细浏览页面的新闻内容没有段落..空格.

帮帮我吧..我是个新手...学做新闻系统十几天了......
我把系统做好了..,..可是当我在浏览新闻内容(新闻详细页)时...内容没有段落格式也没有空格...全部内容只有一段,而且文字都很紧密的连在一起....
我用CSS里的区块搞了一下还是不行...在网上看到说可以用某种插件解决这个问题...当我不知道是什么插件....或者还有什么办法解决?请高手告诉我吧..
:o.我不是计算机专业的所以我找不到别人帮忙....如果这个问题没能解决我很难再有信心学下去......帮一下我吧..谢谢

用这个函数处理一下新闻内容:
[code]
Function HTMLEncode(ByVal str)
    If str = "" Then Exit Function
    str = Replace(str, "&", "&")
    str = Replace(str, "<", "&lt;")
    str = Replace(str, ">", "&gt;")
    str = Replace(str, """", "&quot;")
    str = Replace(str, "    ", "&nbsp;&nbsp;")
    str = Replace(str, VBCr, "")
    str = Replace(str, VBLf & VBLf, "<br/><br/>")
    str = Replace(str, VBLf, "<br/>")
    HTMLEncode = str
End Function
[/code]

我对代码不是很熟悉啊....你能告诉我怎么用吗?是不是直接吧它放在head和head之间?还是要放在别的地方?

你是不是用文本域输入新闻内容,它不支持HTML代码,你可以用HTML编辑器就可以解决以上问题了。

我用文本域上传内容的....能够教一下我怎么用HTML在线编辑器怎么用吗?或者给我一些资料啊?谢谢.........我下午有下载了2个编辑器...可是不知道怎么用啊...我对ASP代码不是很了解..连接数据库都是用DW里面的"服务器行为"连接的..不知道在线编辑器怎么连接啊....

把你要输出的内容经过这个函数处理后再在页面上输出。
原理很简单,就是通过Replace函数来把页面上边的空格和回车替换成IE能认识的空格和回车。
还有,不要在DW上弄太久,尽快转到代码上来。

请问我应该把那个函数放在什么地方啊?我对代码不熟悉......我是自学的

[html]
<%
Function HTMLEncode(ByVal str)
    If str = "" Then Exit Function
    str = Replace(str, "&", "&amp;")
    str = Replace(str, "<", "&lt;")
    str = Replace(str, ">", "&gt;")
    str = Replace(str, """", "&quot;")
    str = Replace(str, "    ", "&nbsp;&nbsp;")
    str = Replace(str, VBCr, "")
    str = Replace(str, VBLf & VBLf, "<br/><br/>")
    str = Replace(str, VBLf, "<br/>")
    HTMLEncode = str
End Function
content="1                          2                   3        4          5            6          5                                                                                       5                                    3333433333                                         333333333333                                    5    "
response.write("我没有经过函数的处理:"&content&"<br>")
content=HTMLEncode("我已经经过函数处理了,IE认识我的空格和回车了:"&content)
response.write(content)
%>
[/html]

运行后什么也没有啊......你能够告诉我这段代码如何用?把他放在哪里?谢谢
Function HTMLEncode(ByVal str)
    If str = "" Then Exit Function
    str = Replace(str, "&", "&amp;")
    str = Replace(str, "<", "&lt;")
    str = Replace(str, ">", "&gt;")
    str = Replace(str, """", "&quot;")
    str = Replace(str, "    ", "&nbsp;&nbsp;")
    str = Replace(str, VBCr, "")
    str = Replace(str, VBLf & VBLf, "<br/><br/>")
    str = Replace(str, VBLf, "<br/>")
    HTMLEncode = str
End Function

Function HTMLEncode(ByVal str)
    If str = "" Then Exit Function
    str = Replace(str, "&", "&amp;")
    str = Replace(str, "<", "&lt;")
    str = Replace(str, ">", "&gt;")
    str = Replace(str, """", "&quot;")
    str = Replace(str, "    ", "&nbsp;&nbsp;")
    str = Replace(str, VBCr, "")
    str = Replace(str, VBLf & VBLf, "<br/><br/>")
    str = Replace(str, VBLf, "<br/>")
    HTMLEncode = str
End Function
请告诉我这段代码怎么用啊..我对代码一点都不懂...我不知道把这段代码粘贴在什么地方............谢谢了...急死我了................................

你可以ewebeditor这个html在线编辑器,使用十分简单
具体见
http://ewebeditor.webasp.net/features.asp

先学些编程的基础知识吧

zheman在上个帖子中说


用法:
HTMLEncode(rs("content"))

qly840118在上个帖子中说

.....哪个不是自己学 这个东西就是有人教 也是带你入门而已   DW是开始 慢慢转到代码上
全DW处理 出来的网页实用性不高 而且会出现很多无用的代码

留言本的内容应该是一个textarea,假设textarea的name是conment,存储数据的ASP文件为save.asp,把这段代码
[code]
Function HTMLEncode(ByVal str)
    If str = "" Then Exit Function
    str = Replace(str, "&", "&amp;")
    str = Replace(str, "<", "&lt;")
    str = Replace(str, ">", "&gt;")
    str = Replace(str, """", "&quot;")
    str = Replace(str, "    ", "&nbsp;&nbsp;")
    str = Replace(str, VBCr, "")
    str = Replace(str, VBLf & VBLf, "<br/><br/>")
    str = Replace(str, VBLf, "<br/>")
    HTMLEncode = str
End Function
[/code]
加入save.asp,然后取值:
db_content=HTMLEncode(rs("content"))
然后把db_content变量的值存入数据库里相对应的字段就可以了!

zheman在上个帖子中说

请问是不是把这段代码放在要显示新闻内容的详细页(即你是假设的save.asp)的<body></body>中?
(然后取值:
db_content=HTMLEncode(rs("content"))然后把db_content变量的值存入数据库里相对应的字段)???取值是在哪里取呢?是不是在代码后面?

留言本是不是有个提交新闻内容的表单,即<form action="xx.asp">看你的action到什么文件,就把代码放到那个文件中。

<form name="form1" method="POST" action="<%=MM_editAction%>">
那个表单的代码是上面这个啊.......................
我该怎么办呢....好难学啊.........................可不可以把这段代码放到新闻的详细页中?我放代码后在设计界面中却看到了刚才放的代码............那段代码显示为文本.......我不知道怎么办...谢谢你这些天对我的问题的解答...........我是学热能专业的.......自己想学网页设计..不过太难了..早上我买了2本有关ASP的书准备认真学习....你是怎么学好的?能够推荐我一些书吗?




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com