Forum Moderators: open

Message Too Old, No Replies

firefox DOM and IE DOM

ie, firefox, DOM

         

samdyk

8:05 am on Apr 27, 2009 (gmt 0)

10+ Year Member



please help me identify the DOM in IE and firefox.

<div id="container" class="box">
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
<p>Paragraph 4</p>
<p>Paragraph 5</p>
</div>

in firefox the div container get 11 children but IE get only 5 children. what is the problem? can anyone explain me?

<script>
function getInfo(nodeID)
{
var con = document.getElementById(nodeID);

alert(con.childNodes.length);
}
</script>

daveVk

11:54 am on Apr 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Firefox and IE treat whitespace differently the extra 6 will be text nodes containing white space (newline,possibly trailing spaces). IE being in error.

samdyk

2:37 am on Apr 28, 2009 (gmt 0)

10+ Year Member



could you be more specific?

and do you know any way to handle this issue? what i want is to display only 5 childrend in firefox.

thanks you!

daveVk

3:18 am on Apr 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See [webmasterworld.com...] and search for "Inconsistent Whitespace Text Nodes in Internet Explorer"

If you do not expect any text nodes among the children then skip them, else skip any text nodes that contain only white space.

If rewriting html is an option, the following layout is ugly but avoids issue.

<div id="container" class="box"
><p>Paragraph 1</p
><p>Paragraph 2</p
><p>Paragraph 3</p
><p>Paragraph 4</p
><p>Paragraph 5</p
></div>