Skip to content

Instantly share code, notes, and snippets.

@cemerson
Created August 24, 2012 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cemerson/3455408 to your computer and use it in GitHub Desktop.
Save cemerson/3455408 to your computer and use it in GitHub Desktop.
Javascript: HTML Encode
function escapeHTMLEncode(str) {
var div = document.createElement(‘div’);
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment