function htmlEscape(sHtml){ return sHtml && sHtml.replace(/[<>&"]/g, function (c) { return { ‘<‘: ‘<‘, ‘>‘: ‘>‘, ‘&‘: ‘&‘, ‘"‘: ‘"‘ }[c]; }); }
JavaScript工具代码
原文:http://www.cnblogs.com/liqipeng/p/6102201.html