Connecting Tech Pros Worldwide Forums | Help | Site Map

replacing innerHTML in xhtml

Denis McMahon
Guest
 
Posts: n/a
#1: Jul 28 '08
Hi

A relative has a web page that they want to work with google checkout,
so it has to be xhtml, as the google scripts require xhtml.

However, I wish to replace the text content of an id'd span.

In html 4.01, I could do this with the innerhtml property, but that's
not supported in xhtml.

Any suggestions? I can find examples that show me how to create an
additional textnode and add text to it, but not ones that show me how to
update or replace [the content of] an existing textnode.

Denis McMahon

Martin Honnen
Guest
 
Posts: n/a
#2: Jul 28 '08

re: replacing innerHTML in xhtml


Denis McMahon wrote:
Quote:
A relative has a web page that they want to work with google checkout,
so it has to be xhtml, as the google scripts require xhtml.
>
However, I wish to replace the text content of an id'd span.
>
In html 4.01, I could do this with the innerhtml property, but that's
not supported in xhtml.
>
Any suggestions? I can find examples that show me how to create an
additional textnode and add text to it, but not ones that show me how to
update or replace [the content of] an existing textnode.
document.getElementById('spanId').firstChild.nodeV alue = 'foo';

However as long as you serve the XHTML document as text/html it should
be no problem at all to use innerHTML, and even if the XHTML is served
as application/xhtml+xml then browsers like Firefox 1.5 and later
support innerHTML for XHTML elements.



--

Martin Honnen
http://JavaScript.FAQTs.com/
Harlan Messinger
Guest
 
Posts: n/a
#3: Jul 28 '08

re: replacing innerHTML in xhtml


Denis McMahon wrote:
Quote:
Hi
>
A relative has a web page that they want to work with google checkout,
so it has to be xhtml, as the google scripts require xhtml.
>
However, I wish to replace the text content of an id'd span.
>
In html 4.01, I could do this with the innerhtml property, but that's
not supported in xhtml.
It won't be supported anyway, because Javascript is case-sensitive, and
innerhtml doesn't exist. Maybe IE has recognized this in quirks mode.
Closed Thread