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);
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);
}
http://www.cnblogs.com/liszt/archive/2011/08/16/2140007.html