function escape2Html(str){
var arrEntities={'lt':'<','gt':'>','nbsp':'','amp':'&','quot':'"'};
return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
}
原文地址http://blog.csdn.net/ywl570717586/article/details/53066401
网友评论