A DOM Core Document Analyzer : DOM Content : Development : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP
JavaScript DHTML Home »  Development   » [  DOM Content  ]   
 



A DOM Core Document Analyzer

Please note that some example is only working under IE or Firefox.


/*
Mastering JavaScript, Premium Edition
by James Jaworski 

ISBN:078212819X
Publisher Sybex CopyRight 2001
*/
<html>
<head><title>DOM Core Analyzer</title>
<script language="JavaScript">
function analyzeDocument() {
 var win = open("","results")
 var doc = win.document
 doc.open()
 doc.writeln("<html><head><title>Results</title></head><body>")
 getDocumentStructure(document.documentElement, doc)
 doc.writeln("</body></html>")
 doc.close()
}
function getDocumentStructure(node, doc) {
 doc.write(node.nodeName)
 var children = node.childNodes
 if(children != null && children.length > 0) {
  doc.writeln("<ul>")
  for(var i=0; i<children.length; ++i) {
   var child = children.item(i)
   doc.write("<li>")
   getDocumentStructure(child, doc)
  }
  doc.writeln("</ul>")
 }
}
</script>
</head>
<body onload="analyzeDocument()">
<h1 align="center">DOM Core Analyzer</h1>
<p>The <code>analyzeDocument()</code> function is used to display a map of the document tree.</p>
<p>It displays the document tree in a separate window.</p>
</body>
</html>

           
       
Related examples in the same category
1.  Define a NodeFilter function to accept only 'img' elements
2.  CSS style sheet a 'window' visual effect
3.  Check DOM Node object whether represents an HTML tag
4.  If a DOM Node object is a Text object
5.  recursively looks at node n and its descendants: replacing with their uppercase equivalents
6.  Creating a Table: Using the insertBefore Method with DOM
7.  Navigating Documents
8.  Adding/Replacing DOM Content
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.