Click here to get back home

replacing innerHTML in xhtml

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
replacing innerHTML in xhtml Denis McMahon 07-28-2008
Posted by Denis McMahon on July 28, 2008, 4:49 am
Please log in for more thread options
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

Posted by Martin Honnen on July 28, 2008, 8:10 am
Please log in for more thread options
Denis McMahon wrote:

> 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.nodeValue = '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/

Posted by Harlan Messinger on July 28, 2008, 12:07 pm
Please log in for more thread options
Denis McMahon wrote:
> 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.

Similar ThreadsPosted
DHTML InnerHTML problem June 10, 2005, 4:13 am
Replacing name with id January 5, 2008, 11:45 pm
css replacing tables August 23, 2004, 11:16 am
Replacing outdated tag attributes June 15, 2006, 6:23 pm
About charset setting and replacing July 14, 2006, 6:29 am
Replacing links en masse on an ftp accessible server only March 10, 2008, 3:35 pm
More accurate testing of XHTML documents with XHTML Proxy June 5, 2006, 6:50 pm
Javascript failing xhtml [xhtml newbe] August 9, 2005, 2:49 pm
Serving XHTML as XHTML does *really* weird things. June 18, 2007, 10:46 am
Old XHTML to new XHTML/CSS: Paragraph line? January 17, 2007, 6:00 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap