Hi

I have a script that loads the objects from a document into an array, or at least it's supposed to.

If you look at this code...

Code:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
 <title>Document</title>
 
 <style type="text/css">
  #layer_1
  {
   position: relative;
   width: 200px;
   height: 200px;
   background-color: #ffffcc;
   border: 1px solid #000000;
   padding: 5px;
  }
 
  #layer_2, #layer_3, #layer_4
  {
   display: none;
  }
 </style>
 
 <script type="text/javascript">
 <!--
 
  var my_object;
 
  function my_object()
  {
   this.document_layers = new Array();
 
   for (var i = 0; i < document.body.childNodes.length; i++)
   {
    if (document.body.childNodes(i).id && document.body.childNodes(i).id != '')
    {
     object_id = document.body.childNodes(i).id;
 
     this.document_layers[object_id] = document.getElementById(object_id);
    }
   }
 
   this.get_length = function ()
   {
    alert(this.document_layers.length);
   }
 
   this.get_width = function (layer_id)
   {
    alert(this.document_layers[layer_id].innerHTML);
   }
  }
 
  function init()
  {
   my_object = new my_object();
  }
 //-->
 </script>
</head>
<body onload="init()">
 <div id="layer_1">Layer 1 Content</div>
 <div id="layer_2">Layer 2 Content</div>
 <div id="layer_3">Layer 3 Content</div>
 <div id="layer_4">Layer 4 Content</div>
 <a href="javascript:my_object.get_length()">Layer Count</a><br />
 <a href="javascript:my_object.get_width('layer_3')">Get Layer Content</a>
</body>
</html>
You can see that the objects in the page are loaded in to an array, but the length of that array is zero (0).

Does anyone know why?

Thanks in advance!