A DOM Core Document Analyzer : DOM Content « Development « JavaScript DHTML






A DOM Core Document Analyzer

 <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><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">h1 center</h1> <p> p <code> p code </code> after p </p> <p>second p</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
close