请教JS高手,IE与netscape兼容问题
代码如下:
<table id="table1" border="1" cellspacing="2" width="555">
<tbody id="tbody1">
<tr>
<td height="16" width="62"><input value="1" type="text"></td>
<td height="16" width="127"> <input value="monitor" type="text">
</td>
<td height="16" width="109"><input value="广东东莞" type="text"></td>
<td height="16" width="92"> <input value="436" type="text"> </td>
<td height="16" width="131"> <input value="04/17/1997"
type="text"> </td>
</tr>
<tr>
<td height="17" width="62"> <input value="2" type="text"> </td>
<td height="17" width="127"> <input value="printer" type="text">
</td>
<td height="17" width="109"><input value="美国加州" type="text"></td>
<td height="17" width="92"> <input value="18" type="text"> </td>
<td height="17" width="131"> <input value="02/13/1998"
type="text"> </td>
</tr>
<tr>
<td height="16" width="62"><input value="3" type="text"></td>
<td height="16" width="127"> <input value="pc" type="text"> </td>
<td height="16" width="109"><input value="台湾" type="text"></td>
<td height="16" width="92"> <input value="143" type="text"> </td>
<td height="16" width="131"> <input value="01/01/2000"
type="text"> </td>
</tr>
</tbody>
</table>
<script language=javascript>
var tbl1 = document.getElementById("table1");
var tbd1 = document.getElementById("tbody1");
alert("table1一共有"+tbd1.childNodes.length+"个子节点");
for(i = 0;i<tbd1.childNodes.length;i++){
alert("第"+i+"个节点:"+tbd1.childNodes[i].nodeName);
}
</script>
输出一个表格的行数,使用标准的DOM语法,在IE中显示正常,“table1一共有3个子节点”
但在netscape中,显示却是:,“table1一共有7个子节点”!!
netscape把空格之类也当作了一个节点,遇到这种情况,如何处理?
高分求教!顶者有分!