By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,460 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,460 IT Pros & Developers. It's quick & easy.

IE DOM

P: n/a
Hello,
maybe it is a silly question, sorry in advance.
If i have a fragment like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<script type="text/javascript">
function t(){
vUl=document.getElementById("c");
alert(vUl.parentNode.getAttribute("id"));
}
</script>
<body>
<ul id="a">
<a href="#" onclick="t()">Root</a>
<li id="b">Level 1</li>
<ul id="c">
<a href="#">Level 1</a>
</ul>
</ul>
</body>
</html>

Then IE6 reports <li id="b"> as parent node for <ul id="c">, that is
apparently wrong for my understanding, FF in opposite works correctly.
Is it a well known bug ? Maybe , there are some workarounds for this issue ?

Best regards

Maxim
Jun 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Maxim Demenko wrote:
Hello,
maybe it is a silly question, sorry in advance.
If i have a fragment like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<script type="text/javascript">
function t(){
vUl=document.getElementById("c");
alert(vUl.parentNode.getAttribute("id"));
}
</script>
<body>
<ul id="a">
<a href="#" onclick="t()">Root</a>
<li id="b">Level 1</li>
<ul id="c">
The above is invalid HTML. A UL can *only* have LI elements as
children, you should mark it up like:

<lu>
<li><a>...</a></li>
<li>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</li>
</il>

Note: closing tags on LI elements are optional, but with nested list the
markup can be very confusing without them (it's pretty confusing with
them too :-) ).
[...]
Then IE6 reports <li id="b"> as parent node for <ul id="c">, that is
apparently wrong for my understanding, FF in opposite works correctly.
Is it a well known bug ? Maybe , there are some workarounds for this
issue ?


The issue is your markup. Browsers will convert it into a DOM depending
on guess work and error correction, the resultant DOM may well be
different in different browsers.

--
Rob
Jun 29 '06 #2

P: n/a
RobG wrote:
[...]

The above is invalid HTML. A UL can *only* have LI elements as
children, you should mark it up like:

<lu>
<li><a>...</a></li>
<li>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</li>
</il>


Owww! that is a hideous mess, sorry... try:

<ul>
<li><a>...</a></li>
<li>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</li>
</ul>

[...]

--
Rob
Jun 29 '06 #3

P: n/a
RobG schrieb:
RobG wrote:
[...]

The above is invalid HTML. A UL can *only* have LI elements as
children, you should mark it up like:

<lu>
<li><a>...</a></li>
<li>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</li>
</il>


Owww! that is a hideous mess, sorry... try:

<ul>
<li><a>...</a></li>
<li>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</li>
</ul>

[...]


Thanks a lot, you saved me hours of headaches!!!

Best regards

Maxim
Jun 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.