这个网页的名字叫:text.asp
<%
' 内容提交前用这个函数
Function HTMLEncode(fString)'HTML加码函数
If Not IsNull(fString) Then
fString = Replace(fString, CHR(38), "&")
fString = Replace(fString, ">", ">")
fString = Replace(fString, "<", "<")
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10), "<br>")
HTMLEncode = fString
End If
End Function
dim aaa
aaa =htmlencode(request("text1"))
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<div align="center">
<form name="form1" method="post" action="text.asp">
<p>
<textarea name="text1" cols="50" rows="10" id="text1"></textarea>
</p>
<p> </p>
<p>
<input type="submit" name="Submit" value="提交">
</p>
<p> <%=aaa%> </p>
<p>
<textarea name="textarea" cols="50" rows="10"><%=aaa%></textarea>
</p>
<p> </p>
<p> </p>
</form>
</div>
</body>
</html
修改时:
Function HTMLEncode(fString)'HTML加码函数
If Not IsNull(fString) Then
fString = Replace(fString, CHR(38), "&")
fString = Replace(fString, ">", ">")
fString = Replace(fString, "<", "<")
fString = Replace(fString, CHR(39), "'")
fString = Replace(fString, CHR(32), " ")
fString = Replace(fString, CHR(34), """)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10), "<br>")
HTMLEncode = fString
End If
End Function
显示的时候再把内容转换过来就可以了
Function HTMLChange(fString)'HTML加码函数
If Not IsNull(fString) Then
fString = Replace(fString, &, "CHR(38)")
fString = Replace(fString, ">", ">")
fString = Replace(fString, "<", "<")
......
HTMLEncode = fString
End If
End Function
评论