本篇文章是对使用javascript过滤html的字符串进行了详细的分析介绍
需要的朋友参考下
复制代码 代码如下:
function DeleteHtmlFromStartToEnd(str begin end) {
str = strreplace(begin + end "");
if (strindexOf(begin) == ) {//没找到
return str;
}
var substr = strsubstring(strindexOf(begin) + beginlength strindexOf(end));
str = strreplace(substr "");
return DeleteHtmlFromStartToEnd(str begin end);
}
var str = <!deleteBegin><!deleteEnd><!deleteBegin><!deleteEnd><!deleteBegin><!deleteEnd><!deleteBegin><!deleteEnd>;
var result = DeleteHtmlFromStartToEnd(str <!deleteBegin> <!deleteEnd>);
alert(result);