<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_DHTML%2FDevelopment%2FDOM_Content</id>
		<title>JavaScript DHTML/Development/DOM Content - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_DHTML%2FDevelopment%2FDOM_Content"/>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_DHTML/Development/DOM_Content&amp;action=history"/>
		<updated>2026-04-04T15:19:00Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_DHTML/Development/DOM_Content&amp;diff=1848&amp;oldid=prev</id>
		<title> в 10:02, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_DHTML/Development/DOM_Content&amp;diff=1848&amp;oldid=prev"/>
				<updated>2010-05-26T10:02:39Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 10:02, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_DHTML/Development/DOM_Content&amp;diff=1849&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_DHTML/Development/DOM_Content&amp;diff=1849&amp;oldid=prev"/>
				<updated>2010-05-26T07:20:00Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Adding/Replacing DOM Content==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;HTML&amp;gt; &lt;br /&gt;
&amp;lt;HEAD&amp;gt; &lt;br /&gt;
&amp;lt;TITLE&amp;gt;A Simple Page&amp;lt;/TITLE&amp;gt;&lt;br /&gt;
&amp;lt;SCRIPT LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
function modify() {&lt;br /&gt;
    var newElem = document.createElement(&amp;quot;P&amp;quot;)&lt;br /&gt;
    newElem.id = &amp;quot;newP&amp;quot;&lt;br /&gt;
    var newText = document.createTextNode(&amp;quot;This is the second paragraph.&amp;quot;)&lt;br /&gt;
    newElem.appendChild(newText)&lt;br /&gt;
    document.body.appendChild(newElem)&lt;br /&gt;
    document.getElementById(&amp;quot;emphasis1&amp;quot;).childNodes[0].nodeValue = &amp;quot;first &amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&lt;br /&gt;
&amp;lt;/HEAD&amp;gt; &lt;br /&gt;
&amp;lt;BODY&amp;gt; &lt;br /&gt;
&amp;lt;BUTTON onClick=&amp;quot;modify()&amp;quot;&amp;gt;Add/Replace Text&amp;lt;/BUTTON&amp;gt;&lt;br /&gt;
&amp;lt;P ID=&amp;quot;paragraph1&amp;quot;&amp;gt;This is the &amp;lt;EM ID=&amp;quot;emphasis1&amp;quot;&amp;gt;one and only &amp;lt;/EM&amp;gt;paragraph on the page.&amp;lt;/P&amp;gt; &lt;br /&gt;
&amp;lt;/BODY&amp;gt; &lt;br /&gt;
&amp;lt;/HTML&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==A DOM Core Document Analyzer==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;DOM Core Analyzer&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;script language=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
function analyzeDocument() {&lt;br /&gt;
 var win = open(&amp;quot;&amp;quot;,&amp;quot;results&amp;quot;)&lt;br /&gt;
 var doc = win.document&lt;br /&gt;
 doc.open()&lt;br /&gt;
 doc.writeln(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;quot;)&lt;br /&gt;
 getDocumentStructure(document.documentElement, doc)&lt;br /&gt;
 doc.writeln(&amp;quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;)&lt;br /&gt;
 doc.close()&lt;br /&gt;
}&lt;br /&gt;
function getDocumentStructure(node, doc) {&lt;br /&gt;
 doc.write(node.nodeName)&lt;br /&gt;
 var children = node.childNodes&lt;br /&gt;
 if(children != null &amp;amp;&amp;amp; children.length &amp;gt; 0) {&lt;br /&gt;
  doc.writeln(&amp;quot;&amp;lt;ul&amp;gt;&amp;quot;)&lt;br /&gt;
  for(var i=0; i&amp;lt;children.length; ++i) {&lt;br /&gt;
   var child = children.item(i)&lt;br /&gt;
   doc.write(&amp;quot;&amp;lt;li&amp;gt;&amp;quot;)&lt;br /&gt;
   getDocumentStructure(child, doc)&lt;br /&gt;
  }&lt;br /&gt;
  doc.writeln(&amp;quot;&amp;lt;/ul&amp;gt;&amp;quot;)&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body onload=&amp;quot;analyzeDocument()&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h1 align=&amp;quot;center&amp;quot;&amp;gt;h1 center&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; p &amp;lt;code&amp;gt; p code &amp;lt;/code&amp;gt; after p &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;second p&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Check DOM Node object whether represents an HTML tag==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Examples From&lt;br /&gt;
JavaScript: The Definitive Guide, Fourth Edition&lt;br /&gt;
Legal matters: these files were created by David Flanagan, and are&lt;br /&gt;
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and&lt;br /&gt;
distribute them for any purpose.  Please note that these examples are&lt;br /&gt;
provided &amp;quot;as-is&amp;quot; and come with no warranty of any kind.&lt;br /&gt;
David Flanagan&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
// This function is passed a DOM Node object and checks to see if that node &lt;br /&gt;
// represents an HTML tag: i.e., if the node is an Element object.  It&lt;br /&gt;
// recursively calls itself on each of the children of the node, testing&lt;br /&gt;
// them in the same way.  It returns the total number of Element objects&lt;br /&gt;
// it encounters.  If you invoke this function by passing it the&lt;br /&gt;
// Document object, it traverses the entire DOM tree.&lt;br /&gt;
function countTags(n) {                        // n is a Node &lt;br /&gt;
    var numtags = 0;                           // Initialize the tag counter&lt;br /&gt;
    if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) // Check if n is an Element&lt;br /&gt;
        numtags++;                             // Increment the counter if so&lt;br /&gt;
    var children = n.childNodes;               // Now get all children of n&lt;br /&gt;
    for(var i=0; i &amp;lt; children.length; i++) {   // Loop through the children&lt;br /&gt;
        numtags += countTags(children[i]);     // Recurse on each one&lt;br /&gt;
    }&lt;br /&gt;
    return numtags;                            // Return total number of tags&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;!-- Here&amp;quot;s an example of how the countTags() function might be used --&amp;gt;&lt;br /&gt;
&amp;lt;body onload=&amp;quot;alert(&amp;quot;This document has &amp;quot; + countTags(document) + &amp;quot; tags&amp;quot;)&amp;quot;&amp;gt;&lt;br /&gt;
This is a &amp;lt;i&amp;gt;sample&amp;lt;/i&amp;gt; document.&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Creating a Table: Using the insertBefore Method with DOM==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;HTML&amp;gt;&lt;br /&gt;
&amp;lt;HEAD&amp;gt;&lt;br /&gt;
&amp;lt;TITLE&amp;gt; Building tables using DOM &amp;lt;/TITLE&amp;gt;&lt;br /&gt;
&amp;lt;/HEAD&amp;gt;&lt;br /&gt;
&amp;lt;BODY ID=&amp;quot;bodyNode&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;SCRIPT LANGUAGE=&amp;quot;JavaScript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
row1column1Node = document.createTextNode(&amp;quot;test&amp;quot;);&lt;br /&gt;
tableElement = document.createElement(&amp;quot;TABLE&amp;quot;);&lt;br /&gt;
tableBodyElement = document.createElement(&amp;quot;TBODY&amp;quot;);&lt;br /&gt;
tr1Element = document.createElement(&amp;quot;TR&amp;quot;);&lt;br /&gt;
tr1td1 = document.createElement(&amp;quot;TD&amp;quot;);&lt;br /&gt;
tr1td2 = tr1td1.cloneNode(true);&lt;br /&gt;
tr2td1 = tr1td1.cloneNode(false);&lt;br /&gt;
tr2td2 = tr1td1.cloneNode(true);&lt;br /&gt;
tr3td1 = tr1td1.cloneNode(false);&lt;br /&gt;
tr3td2 = tr1td1.cloneNode(false);&lt;br /&gt;
tr2 = tr1Element.cloneNode(true);&lt;br /&gt;
tr3 = tr1Element.cloneNode(false);&lt;br /&gt;
row1column2 = row1column1Node.cloneNode(false);&lt;br /&gt;
row2column1 = row1column1Node.cloneNode(true);&lt;br /&gt;
row2column2 = row1column1Node.cloneNode(false);&lt;br /&gt;
row3column1 = row1column1Node.cloneNode(true);&lt;br /&gt;
row3column2 = row1column1Node.cloneNode(false);&lt;br /&gt;
row1column2.nodeValue = &amp;quot;A  &amp;quot;;&lt;br /&gt;
row2column1.nodeValue = &amp;quot;B  &amp;quot;;&lt;br /&gt;
row2column2.nodeValue = &amp;quot;C  &amp;quot;;&lt;br /&gt;
row3column1.nodeValue = &amp;quot;D  &amp;quot;;&lt;br /&gt;
row3column2.nodeValue = &amp;quot;E  &amp;quot;;&lt;br /&gt;
returnValue = tableElement.insertBefore(tableBodyElement);&lt;br /&gt;
tableBodyElement.insertBefore(tr3);&lt;br /&gt;
tableBodyElement.insertBefore(tr2, tr3);&lt;br /&gt;
tableBodyElement.insertBefore(tr1Element, tr2);&lt;br /&gt;
tr1Element.insertBefore(tr1td2);&lt;br /&gt;
tr1Element.insertBefore(tr1td1, tr1td2);&lt;br /&gt;
tr2.insertBefore(tr2td2);&lt;br /&gt;
tr2.insertBefore(tr2td1, tr2td2);&lt;br /&gt;
tr3.insertBefore(tr3td2);&lt;br /&gt;
tr3.insertBefore(tr3td1, tr3td2);&lt;br /&gt;
tr1td2.insertBefore(row1column2);&lt;br /&gt;
tr1td1.insertBefore(row1column1Node);&lt;br /&gt;
tr2td2.insertBefore(row2column2);&lt;br /&gt;
tr2td1.insertBefore(row2column1);&lt;br /&gt;
tr3td2.insertBefore(row3column2);&lt;br /&gt;
tr3td1.insertBefore(row3column1);&lt;br /&gt;
bodyNode.insertBefore(tableElement);&lt;br /&gt;
// --&amp;gt;&lt;br /&gt;
&amp;lt;/SCRIPT&amp;gt;&lt;br /&gt;
&amp;lt;/BODY&amp;gt;&lt;br /&gt;
&amp;lt;/HTML&amp;gt;&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==CSS style sheet a &amp;quot;window&amp;quot; visual effect==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
Examples From&lt;br /&gt;
JavaScript: The Definitive Guide, Fourth Edition&lt;br /&gt;
Legal matters: these files were created by David Flanagan, and are&lt;br /&gt;
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and&lt;br /&gt;
distribute them for any purpose.  Please note that these examples are&lt;br /&gt;
provided &amp;quot;as-is&amp;quot; and come with no warranty of any kind.&lt;br /&gt;
David Flanagan&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * This is a CSS style sheet that defines three style rules that we use&lt;br /&gt;
 * in the body of the document to create a &amp;quot;window&amp;quot; visual effect.&lt;br /&gt;
 * The rules use positioning attributes to set the overall size of the window &lt;br /&gt;
 * and the position of its components.  Changing the size of the window&lt;br /&gt;
 * requires careful changes to positioning attributes in all three rules.&lt;br /&gt;
 **/&lt;br /&gt;
div.window {    /* Specifies size and border of the window */&lt;br /&gt;
    position: absolute;            /* The position is specified elsewhere */&lt;br /&gt;
    width: 300px; height: 200px;   /* Window size, not including borders */&lt;br /&gt;
    border: outset gray 3px;       /* Note 3D &amp;quot;outset&amp;quot; border effect */&lt;br /&gt;
}&lt;br /&gt;
div.titlebar {  /* Specifies position, size, and style of the titlebar */&lt;br /&gt;
    position: absolute;        /* It&amp;quot;s a positioned element */&lt;br /&gt;
    top: 0px; height: 18px;    /* titlebar is 18px + padding and borders */&lt;br /&gt;
    width: 290px;              /* 290 + 5px padding on left and right = 300 */&lt;br /&gt;
    background-color: ActiveCaption;  /* Use system titlebar color */&lt;br /&gt;
    border-bottom: groove black 2px;  /* Titlebar has border on bottom only */&lt;br /&gt;
    padding: 3px 5px 2px 5px;  /* Values clockwise: top, right, bottom, left */&lt;br /&gt;
    font: caption;             /* Use system font for titlebar */&lt;br /&gt;
}&lt;br /&gt;
div.content {   /* Specifies size, position and scrolling for window content */&lt;br /&gt;
    position: absolute;        /* It&amp;quot;s a positioned element */&lt;br /&gt;
    top: 25px;                 /* 18px title+2px border+3px+2px padding */&lt;br /&gt;
    height: 165px;             /* 200px total - 25px titlebar - 10px padding */&lt;br /&gt;
    width: 290px;              /* 300px width - 10px of padding */&lt;br /&gt;
    padding: 5px;              /* allow space on all four sides */&lt;br /&gt;
    overflow: auto;            /* give us scrollbars if we need them */&lt;br /&gt;
    background-color: #ffffff; /* White background by default */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&amp;lt;!-- Here is how we define a window: a &amp;quot;window&amp;quot; div with a titlebar and --&amp;gt;&lt;br /&gt;
&amp;lt;!-- content div nested between them.  Note how position is specified with --&amp;gt;&lt;br /&gt;
&amp;lt;!-- a style attribute that augments the styles from the style sheet --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;window&amp;quot; style=&amp;quot;left: 10px; top: 10px; z-index: 10;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;titlebar&amp;quot;&amp;gt;Test Window&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
1&amp;lt;br&amp;gt;2&amp;lt;br&amp;gt;3&amp;lt;br&amp;gt;4&amp;lt;br&amp;gt;5&amp;lt;br&amp;gt;6&amp;lt;br&amp;gt;7&amp;lt;br&amp;gt;8&amp;lt;br&amp;gt;9&amp;lt;br&amp;gt;0&amp;lt;br&amp;gt; &amp;lt;!--Lots of lines to --&amp;gt;&lt;br /&gt;
1&amp;lt;br&amp;gt;2&amp;lt;br&amp;gt;3&amp;lt;br&amp;gt;4&amp;lt;br&amp;gt;5&amp;lt;br&amp;gt;6&amp;lt;br&amp;gt;7&amp;lt;br&amp;gt;8&amp;lt;br&amp;gt;9&amp;lt;br&amp;gt;0&amp;lt;br&amp;gt; &amp;lt;!--demonstrate scrolling--&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;!-- Here&amp;quot;s another window with different position, color, and font weight --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;window&amp;quot; style=&amp;quot;left: 170px; top: 140px; z-index: 20;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;titlebar&amp;quot;&amp;gt;Another Window&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;content&amp;quot; style=&amp;quot;background-color:#d0d0d0; font-weight:bold;&amp;quot;&amp;gt;&lt;br /&gt;
This is another window.  Its &amp;lt;tt&amp;gt;z-index&amp;lt;/tt&amp;gt; puts it on top of the other one.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Define a NodeFilter function to accept only &amp;quot;img&amp;quot; elements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
Examples From&lt;br /&gt;
JavaScript: The Definitive Guide, Fourth Edition&lt;br /&gt;
Legal matters: these files were created by David Flanagan, and are&lt;br /&gt;
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and&lt;br /&gt;
distribute them for any purpose.  Please note that these examples are&lt;br /&gt;
provided &amp;quot;as-is&amp;quot; and come with no warranty of any kind.&lt;br /&gt;
David Flanagan&lt;br /&gt;
*/&lt;br /&gt;
// Define a NodeFilter function to accept only &amp;lt;img&amp;gt; elements&lt;br /&gt;
function imgfilter(n) {&lt;br /&gt;
   if (n.tagName == &amp;quot;IMG&amp;quot;) return NodeFilter.FILTER_ACCEPT;&lt;br /&gt;
   else return NodeFilter.FILTER_SKIP;&lt;br /&gt;
}&lt;br /&gt;
// Create a NodeIterator to find &amp;lt;img&amp;gt; tags&lt;br /&gt;
var images = document.createNodeIterator(document, // traverse entire document&lt;br /&gt;
  /* only look at Element nodes */ NodeFilter.SHOW_ELEMENT,&lt;br /&gt;
    /* filter out all but &amp;lt;img&amp;gt; */ imgfilter,&lt;br /&gt;
    /* unused in HTML documents */ false);&lt;br /&gt;
// Use the iterator to loop through all images and do something with them&lt;br /&gt;
var image;&lt;br /&gt;
while((image = images.nextNode()) != null) {&lt;br /&gt;
    image.style.visibility = &amp;quot;hidden&amp;quot;;  // Process the image here&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==If a DOM Node object is a Text object==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
Examples From&lt;br /&gt;
JavaScript: The Definitive Guide, Fourth Edition&lt;br /&gt;
Legal matters: these files were created by David Flanagan, and are&lt;br /&gt;
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and&lt;br /&gt;
distribute them for any purpose.  Please note that these examples are&lt;br /&gt;
provided &amp;quot;as-is&amp;quot; and come with no warranty of any kind.&lt;br /&gt;
David Flanagan&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
// This function is passed a DOM Node object and checks to see if that node &lt;br /&gt;
// represents a string of text: i.e., if the node is a Text object.  If&lt;br /&gt;
// so, it returns the length of the string.  If not, it recursively&lt;br /&gt;
// calls itself on each of the children of the node and adds up the&lt;br /&gt;
// total length of the text it finds.  Note that it enumerates the&lt;br /&gt;
// children of a node using the firstChild and nextSibling properties.&lt;br /&gt;
// Note that the function does not recurse when it finds a Text node&lt;br /&gt;
// because Text nodes never have children.&lt;br /&gt;
function countCharacters(n) {               // n is a Node &lt;br /&gt;
    if (n.nodeType == 3 /*Node.TEXT_NODE*/) // Check if n is a Text object&lt;br /&gt;
        return n.length;                    // If so, return its length.&lt;br /&gt;
    // Otherwise, n may have children whose characters we need to count&lt;br /&gt;
    var numchars = 0;  // Used to hold total characters of the children&lt;br /&gt;
    // Instead of using the childNodes property, this loop examines the&lt;br /&gt;
    // children of n using the firstChild and nextSibling properties.&lt;br /&gt;
    for(var m = n.firstChild; m != null; m = m.nextSibling) {&lt;br /&gt;
  numchars += countCharacters(m); // Add up total characters found&lt;br /&gt;
    }&lt;br /&gt;
    return numchars;                    // Return total characters&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
  The onload event handler is an example of how the countCharacters()&lt;br /&gt;
  function might be used.  Note that we only want to count the&lt;br /&gt;
  characters in the &amp;lt;body&amp;gt; of the document, so we pass document.body&lt;br /&gt;
  to the function.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&amp;lt;body onload=&amp;quot;alert(&amp;quot;Document length: &amp;quot; + countCharacters(document.body))&amp;quot;&amp;gt;&lt;br /&gt;
This is a sample document.&amp;lt;p&amp;gt;How long is it?&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Navigating Documents==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
Navigate to                                     Expression&lt;br /&gt;
The first child                                 bodyNode.firstChild or &lt;br /&gt;
                                                bodyNode.childNodes[0]&lt;br /&gt;
The second child                                bodyNode.childNodes[1]&lt;br /&gt;
&lt;br /&gt;
The fourth or last child                        bodyNode.childNodes[4] or &lt;br /&gt;
                                                bodyNode.lastChild&lt;br /&gt;
&lt;br /&gt;
Root&amp;quot;s second child (the text node) from Node 1 Node1.nextSibling&lt;br /&gt;
&lt;br /&gt;
Root&amp;quot;s third child from Node 1                  Node1.nextSibling.nextSibling&lt;br /&gt;
&lt;br /&gt;
Root&amp;quot;s last child                               Node1.nextSibling.nextSibling. nextSibling&lt;br /&gt;
&lt;br /&gt;
Children of the fourth child                    Node1.nextSibling.nextSibling. nextSibling.childNodes[0]&lt;br /&gt;
&lt;br /&gt;
The second &amp;lt;P&amp;gt; from the third &amp;lt;p&amp;gt;               Node3.previousSibling.previous Sibling.previousSibling.childNodes[0]&lt;br /&gt;
&lt;br /&gt;
The grandchild of the &amp;lt;BODY&amp;gt; tag.               bodyNode.firstChild.firstChild&lt;br /&gt;
&lt;br /&gt;
&amp;lt;BODY&amp;gt; root tag from a &amp;lt;P&amp;gt; tag                  Node1.parentNode&lt;br /&gt;
&lt;br /&gt;
The grandchild of the &amp;lt;BODY&amp;gt; and                bodyNode.firstChild.firstChild. parentNode.parentNode &lt;br /&gt;
back to the &amp;lt;body&amp;gt;   &lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==recursively looks at node n and its descendants: replacing with their uppercase equivalents==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Examples From&lt;br /&gt;
JavaScript: The Definitive Guide, Fourth Edition&lt;br /&gt;
Legal matters: these files were created by David Flanagan, and are&lt;br /&gt;
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and&lt;br /&gt;
distribute them for any purpose.  Please note that these examples are&lt;br /&gt;
provided &amp;quot;as-is&amp;quot; and come with no warranty of any kind.&lt;br /&gt;
David Flanagan&lt;br /&gt;
*/&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
// This function recursively looks at node n and its descendants, &lt;br /&gt;
// replacing all Text nodes with their uppercase equivalents.&lt;br /&gt;
function uppercase(n) {&lt;br /&gt;
    if (n.nodeType == 3 /*Node.TEXT_NODE*/) {&lt;br /&gt;
        // If the node is a Text node, create a new Text node that&lt;br /&gt;
        // holds the uppercase version of the node&amp;quot;s text, and use the&lt;br /&gt;
        // replaceChild() method of the parent node to replace the&lt;br /&gt;
        // original node with the new uppercase node.&lt;br /&gt;
        var newNode = document.createTextNode(n.data.toUpperCase());&lt;br /&gt;
        var parent = n.parentNode;&lt;br /&gt;
        parent.replaceChild(newNode, n);&lt;br /&gt;
    }&lt;br /&gt;
    else {&lt;br /&gt;
        // If the node was not a Text node, loop through its children,&lt;br /&gt;
        // and recursively call this function on each child.&lt;br /&gt;
        var kids = n.childNodes;&lt;br /&gt;
        for(var i = 0; i &amp;lt; kids.length; i++) uppercase(kids[i]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;!-- Here is some sample text.  Note that the p tags have id attributes --&amp;gt;&lt;br /&gt;
&amp;lt;p id=&amp;quot;p1&amp;quot;&amp;gt;This &amp;lt;i&amp;gt;is&amp;lt;/i&amp;gt; paragraph 1.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p id=&amp;quot;p2&amp;quot;&amp;gt;This &amp;lt;i&amp;gt;is&amp;lt;/i&amp;gt; paragraph 2.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;!-- Here is a button that invokes the uppercase() function defined above --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Note the call to Document.getElementById() to find the desired node --&amp;gt;&lt;br /&gt;
&amp;lt;button onclick=&amp;quot;uppercase(document.getElementById(&amp;quot;p1&amp;quot;));&amp;quot;&amp;gt;Click Me&amp;lt;/button&amp;gt; &lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>