'字符串内容html化 Function inHTML(str) Dim sTemp sTemp = str inHTML = "" If IsNull(sTemp) = True Then Exit Function End If 'stemp=Replace(stemp, CHR(38), "&") sTemp = Replace(sTemp, "&", "&") sTemp = Replace(sTemp, "<", "<") sTemp = Replace(sTemp, ">", ">") stemp=Replace(stemp, CHR(39), "'") stemp= Replace(stemp, CHR(32), " ") sTemp = Replace(sTemp, Chr(34), """) stemp = Replace(stemp, CHR(13), """") stemp = Replace(stemp, CHR(10), "<br>") inHTML = sTemp End Function '将html字符化 Function outHTML(str) Dim sTemp sTemp = str outHTML = "" If IsNull(sTemp) = True Then Exit Function End If stemp=replace(stemp,"<br>",chr(10)) stemp=replace(stemp,"""",chr(13)) stemp=replace(stemp,""",chr(34)) stemp=replace(stemp," ",chr(32)) stemp=replace(stemp,"'",chr(39)) stemp=replace(stemp,">",">") stemp=replace(stemp,"<","<") stemp=replace(stemp,"&","&") 'stemp=replace(stemp,"&",chr(38)) outHTML = sTemp End Function(鼠标移到代码上去,在代码的顶部会出现四个图标,第一个是查看源代码,第二个是复制代码,第三个是打印代码,第四个是帮助)
用法:
text=inhtml(request("textarea"))'这样就将textarea中的内容转换成了html代码
当显示数据库中这个内容到多行表单方法
<textarea name="textarea" cols="30" rows="30"><%=outhtml(rs("字段名"))%>