473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

replacing innerHTML in xhtml

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
Jul 28 '08 #1
2 3655
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.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/
Jul 28 '08 #2
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.
Jul 28 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: catorcio | last post by:
I'm trying to have some text in my page changed by clicking a button. Googleing around I've discovered that innerText doesn't work with every browser, so I've switched to innerHTML. It works fine...
10
by: oopaevah | last post by:
When using innerHTML to insert xhtml IE5+ mangles the xhtml completely. For example it removes the quotes from attributes. It also does other ridiculous things like on a <div> it will insert the...
6
by: sonic | last post by:
Ok, i am sure everyone is sick of hearing about this. but i've checked about 10 different posts/sites about this issue, and they all say "use DOM" but i think there is more to be said. Perhaps I...
4
by: Dan Michael Heggå | last post by:
Hi, I've working on inplace-editing. My problem is the following: This works in all browsers: myDiv.innerHTML = "<p>...</p>"; but this doesn't work in IE: myDiv.innerHTML =...
4
by: jottevanger | last post by:
Is it me, or is innerHTML in IE7 (and as far as I can tell createNode and importNode) rewriting the HTML to upper case and removing most of the quotation marks? I am trying to copy XHTML into an...
2
by: ars | last post by:
hi everyone i'm using some regular expression to paging, it work's fine in IE but not in Firefox i removed every thing to detect problem but i Can't , the only thing i got, is the innerHtml doent...
7
by: Lorenzo Bettini | last post by:
Hi on the same page I set the innerHTML property of an element to something like my_string + "<br />" then when I try to remove my_string + "<br />" from the innerHTML it fails since the...
1
by: TamusJRoyce | last post by:
I have xsl code which I was hoping could be used to replace one specific tag from an xhtml document and output another xhtml document. xsl has phenomenal potential in data replacing, but coming...
6
by: PaPa | last post by:
I'm not sure this is a javascript issue or an HTML issue. I notice that when I extract the contents of a div using the innerHTML property (?), that I wind up with a literal variable (?) which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.