日期:2014-05-18  浏览次数:20606 次

*****高分求过滤页面内JS的函数*****
请高手提供能够过滤下面内容的函数,先谢了。

<script> ***** </script>
<img   src= "javascript:***** ">
<img   src= "# "   onerror= "***** ">
<img   src= "javascript:bla "   style= "image1-background:   url( 'javascript:bla ');   image2-backgroun:   url( 'javascript:alert%28test%29 ') ">

就是可以执行的js代码最好都能过滤掉。  


------解决方案--------------------
str=trim(str)
If IsNull(Str) Then
CheckStr = " "
End if
str=replace(str, "& ", "&#x26; ")
str=replace(str, ": ", ": ")
str=replace(str, "= ", "&#x3D; ")
str=replace(str, " < ", "&#x3C; ")
str=replace(str, "> ", "&#x3E; ")
str=replace(str, " ", "&#x20; ")
str=Replace(Str, " " " ", "&#34; ")

------解决方案--------------------
http://noscript.net/features
------解决方案--------------------
function RemoveBad(strTemp) {
strTemp = strTemp.replace(/\ <|\> |\ "|\ '|\%|\;|\(|\)|\&|\+|\-/g, " ");
return strTemp;
}