我在后台添加新闻时,保存到数据库之前用下面这个函数处理了用户输入的新闻内容!
<%function HTMLEncode(fString)
fString = replace(fString, ">", ">")
fString = replace(fString, "<", "<")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode = fString
end function%>保存到数据库后,可以看见空格什么的已经转换成html字符存到数据库里了!
在前台读取前用下面这个函数处理从数据库中读取道的新闻内容!
<%function HTMLEncode(fString)
fString = replace(fString,">" ,">" )
fString = replace(fString, "<","<" )
fString = Replace(fString," " ,CHR(32) )
fString = Replace(fString,"" , CHR(13))
fString = Replace(fString,"</P><P>" ,CHR(10) & CHR(10) )
fString = Replace(fString,"<BR>" ,CHR(10) )
HTMLEncode = fString
end function%>这个时候应该把内容中的html字符等转换成空格换行等,可实际上文字全部联起来显示,直到超过表格的宽度,才换行!(html字符均不显示)