Skip to content

Instantly share code, notes, and snippets.

@dushouke
Last active October 9, 2015 12:47
Show Gist options
  • Select an option

  • Save dushouke/3507685 to your computer and use it in GitHub Desktop.

Select an option

Save dushouke/3507685 to your computer and use it in GitHub Desktop.
javascript htmlencode
String.prototype.HtmlEncode = function () {
var temp = document.createElement("div");
(temp.textContent != null) ? (temp.textContent = this) : (temp.innerText = this);
var output = temp.innerHTML;
temp = null;
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment