> No, it does not give any warnings on my ff1.5
ff output:
[..]
Here it does, firefox 1.5 unix. But I've found a solution by myself:
Because two of the DOM nodex are a number and a function (see new test
code), it helps to add a if (typeof y == 'object')...
The test code at the end gives the following output and warnings, just
in case anybody is interested..
Log:
item is a: [object Text], #nodeName gives: #text
item is a: [object HTMLDivElement], #nodeName gives: DIV
item is a: [object Text], #nodeName gives: #text
item is a: [object HTMLDivElement], #nodeName gives: DIV
item is a: [object Text], #nodeName gives: #text
item is a: [object HTMLBRElement], #nodeName gives: BR
item is a: [object HTMLBRElement], #nodeName gives: BR
item is a: [object Text], #nodeName gives: #text
item is a: 8, #nodeName gives: undefined
item is a: function item() { [native code] }, #nodeName gives: undefined
Warning: reference to undefined property y.nodeName
Source File: dom1.html
Line: 9
Warning: reference to undefined property y.nodeName
Source File: dom1.html
Line: 9
<html><head>
<script>
function doit() {
var a = document.getElementById('aa');
var x, y;
for (x in a.childNodes) {
y = a.childNodes[x];
if (y != null) {
//log(typeof y == 'object');
log('item is a: '+y+', #nodeName gives: '+y.nodeName);
}
}
}
function log(s) {
var d = document.getElementById('log');
d.innerHTML += s+'<br/>';
}
</script>
</head>
<body>
<div style="text-decoration: underline;" onclick="doit()">Click here to
set the following contents to sth else:</div>
<div id="aa">
<div>Hi</div>
<div>Test</div>
<br/><br/>
</div>
<div>Log:</div>
<div id="log"></div>
</body>
</html>