注:
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")
%>
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论