过滤js html iframe代码
下面给你一个处理函数
程序代码
'===========================
'函数名:RemoveHtml
'作用:移除HTML|Iframe|有害字符
'参数:OriginStr(需要处理的字符串)
' RemoveLevel(移除等级 0:全部移除|1:只移除Iframe|2:移除Iframe和JS|3:移除有害字符)
'===========================
Public Function RemoveHTML(ByVal originStr,ByVal RemoveLevel)
Dim Str,Reg
Str=OriginStr
On Error Resume Next
Set Reg=New RegExp
Reg.IgnoreCase=True
Reg.Global=True
Select Case RemoveLevel
Case 0
Reg.Pattern = "<(.[^>]*)>"
Str = Reg.Replace(Str, "")
Case 1
Reg.Pattern = "(<iframe(.+?)<\/iframe>)"
Str = Reg.Replace(Str,"")
Case 2
Reg.Pattern = "(<s+cript(.+?)<\/s+cript>)"
Str = Reg.Replace(Str, "")
Reg.Pattern = "(<iframe(.+?)<\/iframe>)"
Str = Reg.Replace(Str,"")
Case 3
Reg.Pattern = "[^\s\w]"
Str = Reg.Replace(Str,"")
End Select
Set Reg = Nothing
RemoveHTML=Str
End Function
用jquery的选择器实现很简单,如获取一个div里所有的input类型的text控件,$("#divname :input[type=text]").val(""),就可以清空所有输入框的值