home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / source_code / dhtmlunl / dhtml.exe / CD Content / Chap15 / dun15_7.txt < prev    next >
Encoding:
Text File  |  1997-12-18  |  1.4 KB  |  56 lines

  1. <HTML>
  2. <HEAD>
  3.   <TITLE>Navigating Page Elements in IE4</TITLE>
  4. </HEAD>
  5.  
  6. <BODY BGCOLOR=white>
  7.  
  8. <P>
  9.   <IMG ID=arrow SRC="arrow.gif" ALIGN=left">
  10.   <FONT FACE="Arial, Helvetica" SIZE=+2>
  11.      Navigating Page Elements in IE4
  12.   </FONT>
  13. </P>
  14.  
  15. <P>The following is the document structure of this web page:
  16.  
  17.   <BLOCKQUOTE>
  18.   <PRE><SCRIPT>
  19.     function enumerateChildElements(pageElement)
  20.     {
  21.       var i = pageElement.sourceIndex + 1;
  22.  
  23.       // Display the root element
  24.       document.writeln(pageElement.tagName);
  25.  
  26.       // Display elements sequentially while they
  27.       // are still contained by pageElement.
  28.       //
  29.       while (i < document.all.length &&
  30.              pageElement.contains(document.all[i]))
  31.       {
  32.         // Indent the element three spaces for each
  33.         // parent between the current element and
  34.         // root element
  35.         //
  36.         parentElement = document.all[i].parentElement;
  37.         while (parentElement != pageElement && parentElement != null)
  38.         {
  39.           parentElement = parentElement.parentElement;
  40.           document.write("   ");
  41.         }
  42.  
  43.         // Display the tag name and move to the next element
  44.         document.writeln("   " + document.all[i].tagName);
  45.         i++;
  46.       }
  47.     }
  48.  
  49.     enumerateChildElements(document.all[0]);
  50.   </SCRIPT></PRE>
  51.   </BLOCKQUOTE>
  52. </P>
  53.  
  54. </BODY>
  55. </HTML>
  56.