1function escapeHtml(str) {
2 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
3}
1function escapeHTML(text) {
2 var replacements= {"<": "<", ">": ">","&": "&", """: """};
3 return text.replace(/[<>&"]/g, function(character) {
4 return replacements[character];
5 });
6}