A DOM Core Document Analyzer : DOM Content : Development JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Development » DOM Content »

 

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>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Development
» DOM Content