Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A complete Javascript DOM 3

Status
Not open for further replies.

theEclipse

Programmer
Dec 27, 1999
1,190
US
Is there anywhere that I can get a complete javascript dom?<br>
it needs to include everything, even:<br>
screen<br>
document<br>
window<br>
everything!!!<br>
<br>
I would like it to be written down in some kind of printable form.
 
I don't know if this is a COMPLETE Javascript DOM, but <A HREF=" TARGET="_new"> has the best concise documentation I've ever seen for Javascript. You can download it as HTML or as printable PDF. Also, browse around <A HREF=" TARGET="_new"> in general. However, be aware that this is slanted a little more towards Netscape, and the DOM for Internet Explorer 4/5 is somwhat different--in some ways more advanced, but also has a few more bugs and security leaks. I'm sure Microsoft has a similar document, but I don't know where to get it.<br>
<br>
Good Luck
 
thanks, I think that will do most of what I need<br>
<br>
<br>
theEclipse<br>
<br>
robacarp.webjump.com
 
I've written a program, but it doesn't work quite right:<br>Two problems, an occasional error message and, even if it did work, it would go on forever, but here is a program to display the entire DOM, except methods(see if you can debug it):<br><br>&lt;html&gt;<br>&lt;script language=&quot;Javascript&quot;&gt;<br>function checkall()<br>{<br>var displaydebug = window.open(&quot;&quot;,&quot;&quot;,&quot;&quot;)<br>for (theprop in window)<br>{<br>displaydebug.document.writeln(&quot;window.&quot;+theprop+&quot;=&quot;)<br>displaydebug.document.writeln(eval(&quot;window.&quot;+theprop)+&quot;&lt;br&gt;&quot;)<br>nextstep(&quot;window.&quot;+theprop)<br>}<br>function nextstep(thisprop)<br>{<br>for (thatprop in eval(thisprop))<br>{<br>displaydebug.document.writeln(thisprop+&quot;.&quot;+thatprop+&quot;=&quot;)<br>displaydebug.document.writeln(eval(thisprop+&quot;.&quot;+thatprop)+&quot;&lt;br&gt;&quot;)<br>if (thisprop.indexOf(&quot;window.&quot;)!=0){nextstep(&quot;window.&quot;+thisprop+&quot;.&quot;+thatprop)}else{nextstep(thisprop+&quot;.&quot;+thatprop)}<br>}<br>}<br>}<br>&lt;/script&gt;<br>&lt;body onLoad=&quot;checkall()&quot;&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;
 
I picked this one up a while ago. It's been pretty useful.<br><br>&lt;HTML&gt;&lt;HEAD&gt;<br><br>&lt;SCRIPT LANGUAGE=&quot;JavaScript&quot;&gt;<br>&lt;!-- Original:&nbsp;&nbsp;Cyanide_7 (<A HREF="mailto:leo7278@hotmail.com">leo7278@hotmail.com</A>) --&gt;<br>&lt;!-- Web Site:&nbsp;&nbsp;<A HREF=" TARGET="_new"> --&gt;<br><br>&lt;!-- This script and many more are available free online at --&gt;<br>&lt;!-- The JavaScript Source!! <A HREF=" TARGET="_new"> --&gt;<br><br>&lt;!-- Begin<br>var objects = new Array(), browser = null, expanded = null;<br><br>// begin objects array with the document<br>objects[0] = new Array(document, &quot;_document&quot;, false);<br><br>function openDOMBrowser(activeElement){<br>// finds index of incoming object by its key<br>activeIndex = arrayIndexOf(objects, activeElement, 1);<br>// toggles its expanded boolean<br>objects[activeIndex][2] = !objects[activeIndex][2];<br>// opens/reopens the window<br>args = &quot;width=500,height=600,left=20,top=20,scrollbars,resizable,top=0,left=0&quot;;<br>browser = window.open('',&quot;DOMBrowser&quot;,args);<br>browser.focus();<br>// clears the expanded array (to avoid infinate loops in the DOM)<br>expanded = new Array();<br>// document is about to be expanded<br>expanded[&quot;_document&quot;] = true;<br>// writes HTML to the window<br>browser.document.open(&quot;text/html&quot;,&quot;replace&quot;);<br>browser.document.writeln(&quot;&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;DOM Browser&lt;/TITLE&gt;&lt;/HEAD&gt;&quot;);<br>browser.document.writeln(&quot;&lt;BODY BGCOLOR=BBBBBB link=FFFFF vlink=FFFFF&gt;&quot;);<br>browser.document.writeln(&quot;&lt;h3&gt;document:&lt;/h3&gt;&lt;ul&gt;&quot;);<br>// calls recurrsive property writing function<br>getProps(document);<br>// finishes writing HTML and closes<br>browser.document.writeln(&quot;&lt;/ul&gt;&lt;/BODY&gt;&lt;/HTML&gt;&quot;);<br>browser.document.close();<br>// returns false for event handlers<br>return false;<br>}<br>// recurrsive function to get properties of objects<br>function getProps(obj){<br>// for loop to run through properties of incoming object<br>for(var prop in obj){<br>browser.document.writeln(&quot;&lt;li&gt;&quot;);<br>// if the property is an object itself, but not null...<br>if(typeof(obj[prop])==&quot;object&quot; && obj[prop]!=null){<br>// get index of object in objects array<br>valIndex = arrayIndexOf(objects, obj[prop], 0);<br>// if not in index array, add it and create its key<br>if(valIndex==-1){<br>valIndex = objects.length;<br>key = ((new Date()).getTime()%10000) + &quot;_&quot; + (Math.floor(Math.random()*10000));<br>objects[valIndex] = new Array(obj[prop], key, false);<br>}<br>// write link for this object to call openDOMBrowser with its key<br>browser.document.writeln(&quot;&lt;b&gt;&quot;+prop+<br>&quot;&lt;/b&gt; : &lt;a href=\&quot;javascript:void(0)\&quot; onClick=\&quot;window.opener.openDOMBrowser('&quot;+<br>objects[valIndex][1]+&quot;');return false;\&quot;&gt;&quot;+(new String(obj[prop])).replace(/&lt;/g,&quot;&lt;&quot;)+&quot;&lt;/a&gt;&quot;);<br>// determine whether object should be expanded/was already expanded<br>if(objects[valIndex][2] && !expanded[objects[valIndex][1]]){<br>// if it needs to be expanded, add to expanded array<br>expanded[objects[valIndex][1]] = true;<br>// write nested list tag and recurrsive call to getProps<br>browser.document.writeln(&quot;&lt;ul&gt;&quot;);<br>getProps(obj[prop]);<br>browser.document.writeln(&quot;&lt;/ul&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;}<br>} else<br>// if not an object, just write property, value pair<br>browser.document.writeln(&quot;&lt;b&gt;&quot;+prop+&quot;&lt;/b&gt; : &quot; + (new String(obj[prop])).replace(/&lt;/g,&quot;&lt;&quot;));<br>browser.document.writeln(&quot;&lt;/li&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;}<br>}<br>// function to find object in an array by field value<br>function arrayIndexOf(array, value, field){<br>var found = false;<br>var index = 0;<br>while(!found && index &lt; array.length){<br>// field may be object reference or key<br>if(array[index][field]==value)<br>found = true;<br>else<br>index++;<br>}<br>return (found)?index:-1;<br>}<br>//&nbsp;&nbsp;End --&gt;<br>&lt;/script&gt;<br>&lt;/HEAD&gt;<br><br>&lt;!-- STEP TWO: Copy this code into the BODY of your HTML document&nbsp;&nbsp;--&gt;<br><br>&lt;BODY&gt;<br><br>&lt;center&gt;<br>&lt;form&gt;<br>&lt;input type=button value=&quot;Open DOM Browser&quot; onClick=&quot;openDOMBrowser('_document');&quot;&gt;<br>&lt;/form&gt;<br>&lt;/center&gt;<br>&lt;/body&gt;&lt;/html&gt;<br><br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
ohmygosh! <br><br>um ACRRHODES, I am not so sure how your code works, so I cant debug it, but thaks.<br><br> <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Lots of books have at least summaries of the IE and Netscape Javascript DOMs and flag what features are in which version of each of the big 2 browsers, e.g. Tom Negrino & Dori Smith's &quot;Visual Quickstart Guide:Javascript&quot; (Peachpit Press, 1999).
 
thanks NickBulka, and philcha too. Both were helpfull <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top