注:
1.对于单标记(如:<hr />,<br />等),因其对网站本身不会构成威胁,故未将单标记纳过过滤范围。
2.参数strHTML:待过滤处理的HTML代码内容
3.参数strTAGs:为待过滤掉的HTML标记名,各标记名以英文逗号( , )为间隔
复制代码 代码如下:
<%
'Wrtten by i{At}CnLei.Com
Function lFilterBadHTML(byval strHTML,byval strTAGs)
Dim objRegExp,strOutput
Dim arrTAG,i
arrTAG=Split(strTAGs,",")
Set objRegExp = New Regexp
strOutput=strHTML
objRegExp.IgnoreCase = True
objRegExp.Global = True
For i=0 to UBound(arrTAG)
objRegExp.Pattern = "<"&arrTAG(i)&"[\s\S]+</"&arrTAG(i)&"*>"
strOutput = objRegExp.Replace(strOutput, "")
Next
Set objRegExp = Nothing
lFilterBadHTML = strOutput
End Function
'Wrtten by i{At}CnLei.Com
Function lFilterBadHTML(byval strHTML,byval strTAGs)
Dim objRegExp,strOutput
Dim arrTAG,i
arrTAG=Split(strTAGs,",")
Set objRegExp = New Regexp
strOutput=strHTML
objRegExp.IgnoreCase = True
objRegExp.Global = True
For i=0 to UBound(arrTAG)
objRegExp.Pattern = "<"&arrTAG(i)&"[\s\S]+</"&arrTAG(i)&"*>"
strOutput = objRegExp.Replace(strOutput, "")
Next
Set objRegExp = Nothing
lFilterBadHTML = strOutput
End Function
'Example
Dim sPageCont
sPageCont= "...网页正文内容..."
sPageCont=FilterBadHTML(sPageCont,"script,iframe,object,table")
%>