javascript conversion from html code to real value
-
29-09-2019 - |
문제
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®
해결책 3
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
다른 팁
If you are getting ® as ®
then unescape
it.
document.getElementById(id).value = unescape(data);
Assuming you're using a server side language (i.e php) there are functions for that.
for example this will work with php:
html_entity_decode($data);
if you're set on using javascript, there's still a way. see the code here.
제휴하지 않습니다 StackOverflow