Nodejs Utililty Methods HTML Escape

List of utility methods to do HTML Escape

Description

The list of methods to do HTML Escape are organized into topic(s).

Method

escapeHtml()
var entityMap = {
    '&': '&',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#39;',
    '/': '&#x2F;'
};
String.prototype.escapeHtml = function() {
...
escapeHtml()
String.prototype.escapeHtml = String.prototype.escapeHtml || (String.prototype.escapeHtml = function() {
  return this.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
});
escape_html()
String.prototype.escape_html = function() {
    return this.replace(/&/g, "&amp;")
               .replace(/</g, "&lt;")
               .replace(/>/g, "&gt;")
               .replace(/"/g, "&quot;");
escape_html()
String.prototype.escape_html = function(){
  var span = document.createElement('span');
  var txt =  document.createTextNode('');
  span.appendChild(txt);
  txt.data = this;
  return span.innerHTML;
};
escape_html()
String.prototype.escape_html = function(){
  var span = document.createElement('span');
  var txt =  document.createTextNode('');
  span.appendChild(txt);
  txt.data = this;
  return span.innerHTML;
};
var Notifer = new function(){
  var self = this;
...
escapelHTML()
String.prototype.escapelHTML = function(){
    return String(this)
        .replace(/&/g, "&amp;")
        .replace(/</g, "&lt;")
        .replace(/>/g, "&gt;")
        .replace(/"/g, "&quot;")
        .replace(/'/g, "&#039;")
        .replace(/\
};
...
htmlEscape()
String.prototype.htmlEscape = function(){
    var span = document.createElement('span');
    var txt =  document.createTextNode('');
    span.appendChild(txt);
    txt.data = this;
    return span.innerHTML;
};
htmlEscape()
String.prototype.htmlEscape = function () {
    return this.replace(/&/g, '%amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;')
        .replace(/'/g, '&#39');
console.log('<script>'.htmlEscape());
htmlEscape()
String.prototype.htmlEscape = function() {
     return $('<div/>').text(this.toString()).html();
};
(function($) {
    $.fn.hasScrollBar = function() {
        if (this.height() < 0) {
            return false;
        return this.get(0).scrollHeight > this.height();
...
htmlEscape()
String.prototype.htmlEscape = function (){
    var escapedStr = String(this).replace(/&/g, '&amp;');
    escapedStr = escapedStr.replace(/\s/g, '&nbsp;');
    return escapedStr;
var text = 'This is for testing';
console.log(text);
text = text.htmlEscape(); 
console.log(text);
...