<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML代码过滤工具-(搜索引擎模拟抓取效果)</title>
<style type="text/css">
textarea{width:80%;height:400px;}
</style>
</head>
<body>
<form>
<textarea id="code">
<li>
<em></em><a href="/html/ajax/index.html">Ajax</a>
<a href="/html/Javascript/index.html">Javascript</a>
<a href="/html/DOM/index.html">DOM</a><br>
<a href="/html/XML-web/index.html">XML</a>
<a href="/html/regular-expressions/index.html">正则表达式</a>
<a href="/html/seo/index.html">网站优化</a> <a>...</a>
</li>
</textarea><br />
<input type="button" value="过滤HTML代码" onclick="setContent()" />
<input type="reset" value="reset" />
</form>
<script type="text/javascript">
function $id(i) {return document.getElementById(i)}
function setContent() {
var obj = document.getElementById('code');
obj.value = obj.value.replace(/<\/?[^>]*>/g,''); //去除HTML tag
obj.value = obj.value.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
obj.value = obj.value.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
//alert(obj.value);
}
</script>
</body>
</html>