文章提供一四款js 过滤html标签代码哦,他们利用各种方法来过滤html标签代码,这些代码都是非常不错的哦,好了来看看吧。
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>js 过滤html标签</title>
<script language="网页特效">
function covertfromxmltag(value) {
value = value.split("&").join("&");
value = value.split("<").join("<");
value = value.split(">").join(">");
value = value.split('"').join(""");
value = value.split(" ").join(" ");
value = value.split("r").join("");
value = value.split("n").join("<br/>");
return value;
}
function escapehtml(value) {
with (document.createelement("div")) {
appendchild(document.createtextnode(value));
return innerhtml.replace(/"/g, """);
}
}
function jsp教程asshtml()
{
str = "<a href="xxx.asp教程"><div>1234567</div>89</a>";
alert(str.replace(/<.*?>/g,""));
}
function htmlencode(str) {
str = str.replace(/&/g, '&');
str = str.replace(/</g, '<');
str = str.replace(/>/g, '>');
str = str.replace(/(?:t| |v|r)*n/g, '<br />');
str = str.replace(/ /g, ' ');
str = str.replace(/t/g, ' ');
str = str.replace(/x22/g, '"');
str = str.replace(/x27/g, ''');
return str;
}
</script>
</head>
<body>
</body>
</html>