从数据库调用字段的内容在网页上显示的时候不换行也不空格

ASP代码如下,请问怎么改啊??<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><!--#includefile="Connections/s... ASP代码如下,请问怎么改啊??
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/swsj.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_swsj_STRING
Recordset1.Source = "SELECT * FROM hnswsj"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<div align="center"><%=(Recordset1.Fields.Item("news_title").Value)%>
</div>
<p><%=(Recordset1.Fields.Item("news_content").Value)%></p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
展开
 我来答
百度网友7a01259
2008-08-19 · TA获得超过582个赞
知道小有建树答主
回答量:1120
采纳率:0%
帮助的人:1415万
展开全部
将以下代码放入到一个asp文件中,比如code.asp
之后,将code.asp放入到你这个显示不换行的页面的顶部。
格式<!--#include file="code.asp"-->
file="路径/文件" 根据你放文件的位置来设定

最后,将要格式化换行显示的那个地方,添上ubbdecode即可。
<%=ubbdecode(Recordset1.Fields.Item("news_content").Value)%>

<%''''''''''''''''''''''将下面代码放入到asp文件中 code

Function UBBDecode(str)
Dim oReg
Dim strTmp
Set oReg=New RegExp
strTmp=str
oReg.Global=True
oReg.IgnoreCase=True

strTmp = Replace(strTmp, CHR(38), "&")
strTmp = replace(strTmp, ">", ">")
strTmp= replace(strTmp, "<", "<")
strTmp = Replace(strTmp, CHR(39), "'")
strTmp = Replace(strTmp, CHR(32), " ")
strTmp= Replace(strTmp, CHR(34), """)
strTmp = Replace(strTmp, CHR(13), "")
strTmp = Replace(strTmp, CHR(10), "<br/>")

'下划线
oReg.Pattern="\[U\]"
strTmp=oReg.Replace(strTmp,"<U>")
oReg.Pattern="\[\/U\]"
strTmp=oReg.Replace(strTmp,"</U>")
'粗体
oReg.Pattern="\[B\]"
strTmp=oReg.Replace(strTmp,"<B>")
oReg.Pattern="\[\/B\]"
strTmp=oReg.Replace(strTmp,"</B>")
'斜体
oReg.Pattern="\[I\]"
strTmp=oReg.Replace(strTmp,"<I>")
oReg.Pattern="\[\/I\]"
strTmp=oReg.Replace(strTmp,"</I>")
'删除线
oReg.Pattern="\[S\]"
strTmp=oReg.Replace(strTmp,"<STRIKE>")
oReg.Pattern="\[\/S\]"
strTmp=oReg.Replace(strTmp,"</STRIKE>")
'上标
oReg.Pattern="\[SUP\]"
strTmp=oReg.Replace(strTmp,"<SUP>")
oReg.Pattern="\[\/SUP\]"
strTmp=oReg.Replace(strTmp,"</SUP>")
'上标
oReg.Pattern="\[SUB\]"
strTmp=oReg.Replace(strTmp,"<SUB>")
oReg.Pattern="\[\/SUB\]"
strTmp=oReg.Replace(strTmp,"</SUB>")
'向中看齐
oReg.Pattern="\[C\]"
strTmp=oReg.Replace(strTmp,"<CENTER>")
oReg.Pattern="\[\/C\]"
strTmp=oReg.Replace(strTmp,"</CENTER>")
'超链接
oReg.Pattern="\[URL\=([a-zA-Z0-9\-\_\/\:\.\?\&\%\+\=]+)\](.+)\[\/URL\]"
strTmp=oReg.Replace(strTmp,"<A HREF=""$1"" TARGET=""_BLANK"">$2</A>")
'邮件超链接
oReg.Pattern="\[MAIL\=([a-zA-Z0-9\-\_\.\?\@]+)\](.+)\[\/MAIL\]"
strTmp=oReg.Replace(strTmp,"<A HREF=""mailto:$1"">$2</A>")
'图片
oReg.Pattern="\[IMG\]([a-zA-Z0-9\-\_\/\:\.\?\&\%\+\=]+)\[\/IMG\]"
strTmp=oReg.Replace(strTmp,"<IMG SRC=""$1"" BORDER=""0"">")
'飞行字
oReg.Pattern="\[FLY\]"
strTmp=oReg.Replace(strTmp,"<MARQUEE>")
oReg.Pattern="\[\/FLY\]"
strTmp=oReg.Replace(strTmp,"</MARQUEE>")
'移动
oReg.Pattern="\[MOVE\]"
strTmp=oReg.Replace(strTmp,"<MARQUEE>")
oReg.Pattern="\[\/MOVE\]"
strTmp=oReg.Replace(strTmp,"</MARQUEE>")

'字体颜色
oReg.Pattern="\[COLOR\=(\#[0-9A-Fa-f]{6})\]"
strTmp=oReg.Replace(strTmp,"<FONT COLOR=""$1"">")
'字体阴影
oReg.Pattern="\[SHADOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/SHADOW]"
strTmp=oReg.Replace(strTmp,"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>")
'字体发光
oReg.Pattern="\[GLOW=*([0-9]*),*(#*[a-z0-9]*),*([0-9]*)\](.[^\[]*)\[\/GLOW]"
strTmp=oReg.Replace(strTmp,"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>")
'字体大小
oReg.Pattern="\[SIZE\=([1-7])\]"
strTmp=oReg.Replace(strTmp,"<FONT SIZE=""$1"">")
'字体名称
oReg.Pattern="\[FONT\=([^\]\[\s]+)\]"
strTmp=oReg.Replace(strTmp,"<FONT FACE=""$1"">")
'字体相关属性结尾
oReg.Pattern="\[\/COLOR\]"
strTmp=oReg.Replace(strTmp,"</FONT>")
oReg.Pattern="\[\/SIZE\]"
strTmp=oReg.Replace(strTmp,"</FONT>")
oReg.Pattern="\[\/FONT\]"
strTmp=oReg.Replace(strTmp,"</FONT>")
'-----------------------以下是表情代码----------------------
oReg.Pattern="\/\/smail"
strTemp=oReg.Replace(strTemp,"<IMG SRC=""/images/smail.gif"">")
oReg.Pattern="\/\/cool"
strTemp=oReg.Replace(strTemp,"<IMG SRC=""/images/cool.gif"">")
oReg.Pattern="\/\/gege"
strTemp=oReg.Replace(strTemp,"<IMG SRC=""/images/gege.gif"">")
oReg.Pattern="\/\/mm"
strTemp=oReg.Replace(strTemp,"<IMG SRC=""/images/mm.gif"">")
'-----------------------------------------------------------
UBBDecode=strTmp
End Function
%>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式