<html>
<head>
<title>Abakada DHTML Demo: Examining the Element Hierarchy</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="JScript">
function fetchHierarchy ( ) {
var depth = 0;
var msg = document.all ( 0 ).tagName;
for ( i=1; i < document.all.length; i ++ ) {
if ( document.all ( i-1 ).contains ( document.all ( i ) ) == true ) depth ++;
else {
var elParent = document.all ( i-1 ).parentElement;
for ( ; depth > 0; depth -- ) {
if ( elParent.contains ( document.all ( i ) ) == true ) break;
elParent = elParent.parentElement;
}
}
msg += "\n";
for ( j=1; j <= depth; j ++ )
msg += " ";
msg += document.all ( i ).tagName;
}
alert ( "This document contains: \n" + msg );
}
//-->
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>Abakada DHTML Demo: Examining the <span class="hilite">Element Hierarchy</span></h2></div>
<hr size=1 width=92%>
<center>
<p>Every HTML document consists of a combination of HTML elements and their attributes.</p>
<p>These elements define the structure of the document and how the content is presented.</p>
<p>Using the <b>Document Object Model</b>, or <b>DOM</b>, we can dynamically examine and modify these elements and their attributes.</p>
<p><input type="Button" value="Get HTML Hierarchy" onclick="fetchHierarchy ( )"></p>
</center>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>