Javascript String htmlEncode()
String.prototype.htmlEncode = function () { return String(this) .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/</g, '<') .replace(/>/g, '>'); }
String.prototype.HTMLEncode = function() { var temp = document.createElement ("div"); (temp.textContent != null) ? (temp.textContent = this) : (temp.innerText = this); var output = temp.innerHTML; temp = null; /* ww w . j a v a 2 s .c om*/ return output; }