[Javascript] createTextNode and special characters
Immanuel Normann
normann at dfki.de
Sun May 26 09:44:30 CDT 2002
Dear Lester Novros,
thank you very much for your help! I posted my problem to several mailing-lists and you are the first who replied a real solution.
> > I want to create dynamically text with special characters like ä
> > Therefore I want to use document.createTextNode('ä');
>
> Ah, took me a while to figure that one out. 'createTextNode' does exactly what
> it says, it creates a *text* node. The '&foo;' notation, however, is an HTML
> construct and is not interpreted as such in a text node. What you want is the
> 'innerHTML' property of the node, like this:
>
> var t = document.createElement('div');
> t.innerHTML = 'ä';
> document.body.appendChild(t);
>
> Then, the '&foo;' construct *is* interpreted as HTML which will yield the
> desired result.
It is the first time I am faced to that 'innerHTML', so I looked at w3.org for further information. Thereby I came across a controversial discussion about 'innerHTML' and DOM-standardization.
For those who are interested in this discussion, enter the keyword 'innerHTML' into the search form of the 'W3C mailing-list search service' (http://www.w3.org/Search/Mail/Public/)
and select from the 'search in'-select-box:
www-dom (Mailing list for the DOM Specifications) or
www-dom-ts (Mailing list for the DOM Conformance Test Suites)
Best,
Immanuel Normann
More information about the Javascript
mailing list