Nodejs HTML Unescape unescapeHtmlEntities()

Here you can find the source of unescapeHtmlEntities()

Method Source Code

// Unescape HTML entities
String.prototype.unescapeHtmlEntities = function () {
   try{/*from w  ww .j  a  v  a2s.c  o m*/
      var temp = document.createElement('textarea');
    temp.innerHTML = this;
    return temp.value;
   }catch(e){
      return this;
   }
}

Related

  1. unescapeHtml()
    String.prototype.unescapeHtml = function () {
        var temp = document.createElement("div");
        temp.innerHTML = this;
        var result = temp.childNodes.length === 0 ? "" : temp.childNodes[0].nodeValue;
        if(temp.firstChild) temp.removeChild(temp.firstChild);
        return result;
    };
    
  2. unescapeHtml()
    String.prototype.unescapeHtml = function () {
      var temp = document.createElement("div");
      temp.innerHTML = this;
      var result = "";
      for (var i = 0; i < temp.childNodes.length; i++) {
       result = result + temp.childNodes[i].nodeValue;
      temp.removeChild(temp.firstChild)
      return result;
    ...
    
  3. unescapeHtml()
    String.prototype.unescapeHtml = function () {
        var temp = document.createElement("div");
        temp.innerHTML = this;
        var result = temp.childNodes.length === 0 ? "" : temp.childNodes[0].nodeValue;
        if(temp.firstChild) temp.removeChild(temp.firstChild);
        return result;
    };
    
  4. unescapeHtml()
    String.prototype.unescapeHtml = function () {
        var temp = document.createElement("div");
        temp.innerHTML = this;
        var result = temp.childNodes[0].nodeValue;
        temp.removeChild(temp.firstChild);
        return result;
    
  5. unescapeHtmlEntities()
    String.prototype.unescapeHtmlEntities = function () {
      try{
        var temp = document.createElement('textarea');
        temp.innerHTML = this;
        return temp.value;
      }catch(e){
        return this;