<script LANGUAGE="JavaScript">
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防注入漏洞过滤函数
<script src="http://www.wozhuye.com/index.php?m=digg&c=index&a=init&id=20-57-2"></script>