I appologize for the novice question. I believe in am using standard ECMA.
Can someone explain to me why the following script works in IE but does not
work in Firefox, Mozila, or Opera?
++++++++++++++++++++++++++++++++++
<html>
<head>
</head>
<body>
<ul id="myUL">
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
<li>List Item 4</li>
<li>List Item 5</li>
<li>List Item 6</li>
</ul>
<script type="text/javascript">
var ulist = document.getElementById("myUL");
alert ("childNodes[0].tagName: " +
document.getElementById("myUL").childNodes[0].tagName + "\n" +
"childNodes[0].firstChild.nodeValue: " +
document.getElementById("myUL").childNodes[0].firstChild.nodeValue + "\n" +
"childNodes[1].firstChild.nodeValue: " +
document.getElementById("myUL").childNodes[1].firstChild.nodeValue + "\n" +
"childNodes[2].firstChild.nodeValue: " +
document.getElementById("myUL").childNodes[2].firstChild.nodeValue + "\n" +
"childNodes[3].firstChild.nodeValue: " +
document.getElementById("myUL").childNodes[3].firstChild.nodeValue + "\n" +
"childNodes[4].firstChild.nodeValue: " +
document.getElementById("myUL").childNodes[4].firstChild.nodeValue + "\n" +
"childNodes[5].firstChild.nodeValue: " +
document.getElementById("myUL").childNodes[5].firstChild.nodeValue);
</script>
</body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
Firefox says document.getElementById("myUL").childNodes[0].firstChild 'has
no properties'.
Then I tried the following script:
++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++
<html>
<head>
</head>
<body>
<ul id="myUL">
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
<li>List Item 4</li>
<li>List Item 5</li>
<li>List Item 6</li>
</ul>
<script type="text/javascript">
var ulist = document.getElementById("myUL");
alert ("nodeType " + document.getElementById("myUL").nodeType + "\n" +
"tagName " + document.getElementById("myUL").tagName + "\n" +
"length " + document.getElementById("myUL").length + "\n" +
"innerHTML \n" + document.getElementById("myUL").innerHTML + "\n" +
"childNodes[0].tagName " +
document.getElementById("myUL").childNodes[0].tagName + "\n");
</script>
</body>
</html>
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
The output from that was:
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++
nodeType 1
tagName UL
length undefined
innerHTML
<LI>List Item 1</LI>
<LI>List Item 2</LI>
<LI>List Item 3</LI>
<LI>List Item 4</LI>
<LI>List Item 5</LI>
<LI>List Item 6</LI>
childNodes[0].tagName undefined
++++++++++++++++++++++++++++++++++++++++++++++++++ +++
Why is childNodes[0] undefined?
Thanks in advance,
Joe Cox