Firefox innerHTML bug?

N

nilsandi

Hi folks,

I have a problem using Mozilla Firefox 2.0.0.7 and the innerHTML
function.
I am using custom tags in my application, which are to be found and
parsed by some javaScript program, which translates them into proper
HTML.
The contents of the XHTML document is as folows:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:tf >
<head>
<meta http-equiv="Content-Type" content="application/xml+xhtml;
charset=utf-8" />
<script type="text/javascript" src="js/transform.js"></script>
</head>
<body onload="transform();">
<tf:form serv="...">
<tf:anchor xpath="..." />
Open account:
<tf:list xpath="..." /><br />
<ul>
<li><a href="...">Link</a></li>
</ul>
</tf:form>
</body>
</html>


In the JavaScript program, I get the contents of the BODY tag as
follows:
node = document.getElementsByTagName('body')[0];
contents = node.innerHTML;

But in this case, an alert(contents); or using firebug delivers the
following as the body's innerHTML:



<tf:form serv="...">
<tf:anchor xpath="..." />
Mandanten öffnen:
<tf:list xpath="...">
<br />
</tf:list>
</tf:anchor>
</tf:form>
<ul>
<li><a href="...">Link</a></li>
</ul>


which is curious, because the <ul>-Tag (the enumeration) is no longer
encapsed by the <tf:form>-Tag. Why?
Note that I have set the xml namespace Prefix, but I can't figure out
what I've done wrong so far.

Anyone got suggestions?
Thank you in advance.

Bye, Nils
 
H

Henry

The contents of the XHTML document is as folows:

Your document is not XHTML it is tag soup HTML (if not innerHTML would
be a non-starter).

<tf:anchor xpath="..." />
^^
Tag soup HTML parsers tend to disregard this XML style empty element
mark up, and instead take <XXXXX /> as a single instance of an opening
tag. Inferring any corresponding closing tags as required.
But in this case, an alert(contents); or using firebug delivers the
following as the body's innerHTML:

<tf:form serv="...">
<tf:anchor xpath="..." />
Mandanten ?ffnen:
<tf:list xpath="...">
<br />
</tf:list>
</tf:anchor>
</tf:form>
<ul>
<li><a href="...">Link</a></li>
</ul>

which is curious, because ...

Given that input, any outcome from an HTML parser should be seen as
unexpected. There are certainly no grounds for expecting any one thing
rather than any other.
 
P

Peter Michaux

Hi folks,

I have a problem using Mozilla Firefox 2.0.0.7 and the innerHTML
function.
I am using custom tags in my application, which are to be found and
parsed by some javaScript program, which translates them into proper
HTML.
The contents of the XHTML document is as folows:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:tf >

Why try to use XHTML?

<URL: http://www.thewebcreator.net/2007/04/16/why-you-should-be-using-html-401-instead-of-xhtml/>

<URL: http://www.webdevout.net/articles/beware-of-xhtml>

Peter
 
T

Thomas 'PointedEars' Lahn

Elements, not tags.

Only JavaScript (Netscape/Gecko), or any ECMAScript implementation?

That is not a proper XML namespace declaration:

http://www.w3.org/TR/REC-xml-names/#ns-decl
http://www.w3.org/TR/REC-xml/#NT-Attribute
Why try to use XHTML?

Probably because of the eXtensible? The OP's use indicates one of the rare
valid reasons for preferring XHTML over HTML. However, the translation into
HTML should be done server-side with XSLT or a template engine provided by
the server maybe using that (even though that would be possible client-side
as well). No need to reinvent the wheel worse than before.

http://developer.mozilla.org/en/docs/XSLT


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top