javascripthtmlnon-unicode

javascript conversion from html code to real value


I have a textbox and i have values in database like ® which is equal to ® .I fetch data and write it into textbox but it writes the data as it is.The code part is like this

var data=database_values;//here there is data like this "DOLBY®"
document.getElementById(id).value = data;

I want to make the textbox value DOLBY® not DOLBY®


Solution

  • Hi i found a way to unescape html code.Here is the function

    function unescapeHTML(html) {
    var tempHtmlNode = document.createElement("tempDiv");
    tempHtmlNode.innerHTML = html;
    if(tempHtmlNode.innerText)
    return tempHtmlNode.innerText; // IE
    return tempHtmlNode.textContent; // FF
    
    }
    

    Thanks for your help anyway