String=Server.HTMLEncode(String)
'String=Replace(String,"<","〈")
'String=Replace(String,">","〉")
String=Replace(String,CHR(32)," ")
String=Replace(String,CHR(13)&CHR(10), "<br>")
FormatText=String
End Function
Function FormatCode(String) '''完全原样,可防html,可用作显示源代码。
String="<xmp>"&String&"</xmp>"
FormatCode=String
End Function
Function FormatHTML(String) '''限制无法
使用on.....事件,无法使用JavaScript。
String=Replace(String,"onmouseover","0nmouseover",1,-1,vbTextCompare)
String=Replace(String,"onmouseout","0nmouseout",1,-1,vbTextCompare)
String=Replace(String,"onmousedown","0nmousedown",1,-1,vbTextCompare)
String=Replace(String,"onmouseup","0nmouseup",1,-1,vbTextCompare)
String=Replace(String,"onmousemove","0nmousemove",1,-1,vbTextCompare)
String=Replace(String,"onclick","0nclick",1,-1,vbTextCompare)
String=Replace(String,"ondblclick","0ndblclick",1,-1,vbTextCompare)
String=Replace(String,"onkeypress","0nkeypress",1,-1,vbTextCompare)
String=Replace(String,"onkeydown","0nkeydown",1,-1,vbTextCompare)
String=Replace(String,"onkeyup","0nkeyup",1,-1,vbTextCompare) '各种事件
String=Replace(String,"Script:","Script:",1,-1,vbTextCompare) 'JavaScript:,JScript:VBScript:
String=Replace(String,"<script","<xmp><script",1,-1,vbTextCompare)
String=Replace(String,"</script>","</script></xmp>",1,-1,vbTextCompare) '<script>...</script>标签
FormatHTML=String
End Function
Function FormatHTMLEx(String) '''不作任何限制
FormatHTMLEx=String
End Function
Function FormatSQL(String) '''防止sql语句出错
String=Replace(String,"'","''")
FormatSQL=String
End Function
代码(大小有需要可以调):
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>练习使用HTML</title>
</head>
<body>
<center>
<table border="1px" cellpadding="0px" cellspacing="0px">
<tr>
<td colspan="4" height="60px"></td>
</tr>
<tr>
<td width="200px" height="60px"></td>
<td width="200px" height="60px"></td>
<td width="200px" height="60px"></td>
<td width="200px" height="60px"></td>
</tr>
<tr>
<td colspan="4" height="60px"></td>
</tr>
<tr>
<td colspan="4" height="60px"></td>
</tr>
<tr>
<td colspan="4" height="60px"></td>
</tr>
<tr>
<td colspan="4" height="60px"></td>
</tr>
</table>
</center>
</body>
</html>
运行效果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)