js 过滤html标签代码

文章提供一四款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("&amp;");
    value = value.split("<").join("&lt;");
    value = value.split(">").join("&gt;");
    value = value.split('"').join("&quot;");
    value = value.split(" ").join("&nbsp;");
    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, "&quot;");
    }
}

function jsp教程asshtml()
{
 str = "<a href="xxx.asp教程"><div>1234567</div>89</a>";
 alert(str.replace(/<.*?>/g,""));
}

function htmlencode(str) {
 str = str.replace(/&/g, '&amp;');
 str = str.replace(/</g, '&lt;');
 str = str.replace(/>/g, '&gt;');
 str = str.replace(/(?:t| |v|r)*n/g, '<br />');
 str = str.replace(/  /g, '&nbsp; ');
 str = str.replace(/t/g, '&nbsp; &nbsp; ');
 str = str.replace(/x22/g, '&quot;');
 str = str.replace(/x27/g, '&#39;');
 return str;
}

</script>
</head>

<body>
</body>
</html>

更多详细内容请查看:http://www.111cn.net/wy/js-ajax/34771.htm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值