<script LANGUAGE=" Java Script"> function check(inputStr) { if (typeof(inputStr) != "string") { return inputStr; } var tmpValue = inputStr; // www.2cto.com 以下搜索字符串中的特殊字符,如果存在,则替换成"" while (tmpValue.indexOf(';') > -1) { tmpValue = tmpValue.replace(';',''); } while (tmpValue.indexOf('<') > -1) { tmpValue = tmpValue.replace('<',''); } while (tmpValue.indexOf('>') > -1) { tmpValue = tmpValue.replace('>',''); } while (tmpValue.indexOf('--') > -1) { tmpValue = tmpValue.replace('--',''); } while (tmpValue.indexOf(",") > -1) { tmpValue = tmpValue.replace(",",""); } while (tmpValue.indexOf("'") > -1) { tmpValue = tmpValue.replace("'",""); } while (tmpValue.indexOf("?") > -1) { tmpValue = tmpValue.replace("?",""); } document.getElementById("txt1").value = tmpValue; //重新显示更改后的变量 } </script>
查看更多关于有用的javascript防注入漏洞过滤函数 - 网站安全的详细内容...