看不懂你的程序。
不过错误出在下面
var y=x.childNodes;//x.childNodes????,y是取不到值的
for (var i=0;i<y.length;i++)//所以y.length出错

解决方案 »

  1.   

    请教大虾, 如果程式改成如下,为什么错了啊?
    function count_(n)
    {
        var x=0;
         if (n.nodeType==1)
        x++;
    while (n.nextSibling!=null)
    {
         n=n.nextSiblig;
     x+=count(n);
    }
    }
      

  2.   

    程序目的是想统计HTML节点的个数,不知这样写法对否?请教大虾!
    <html>
    <head>
    <head>
    <script language='javascript'>
    function count_(n)
    {
        var x=0;
         if (n.nodeType==1)
        x++;
    while (n.nextSibling!=null)
    {
         n=n.nextSiblig;
     x+=count(n);
    }
    }</script>
    </head>
    <body onload='alert("count:"+count(document)+"!")' >
    </body> 
    </html>