please dont rip this site
The All Collection

Note : The All collection is Internet Explorer 4.0 specific. As Netscape doesn't support scripting for every HTML element, it doesn't support the All collection.

The All collection is an ordered, indexed array, containing a reference to every opening HTML element in a document. For example, consider the following document:

<HTML>
<HEAD>
<TITLE>Test Document</TITLE>
</HEAD>
<BODY>
<P>This is a test
<HR>
</BODY>
</HTML>

The all collection would be indexed from 0 to 5, with the elements being positioned:

Element All index
<HTML> 0
<HEAD> 1
<TITLE> 2
<BODY> 3
<P> 4
<HR> 5

Element Object would normally be retrieved by their index in the All collection (for example, above document.all(3) contains a reference to the <BODY> element), but a string value can be used, as long as that string is a valid identifier (ID attribute value) for an element in the document.

E.g., changing the above example to:

<HTML>
<HEAD>
<TITLE ID="Title1">Test Document</TITLE>
</HEAD>
<BODY>
<P>This is a test
<HR>
</BODY>
</HTML>

...would mean that document.all('Title1') would be a reference to the <TITLE> element (whose ID is 'Title1'). This would be the same as document.all(2). Note that it is also equivalent to using document.all.item('Title1') (see the item method below).

Note : The All collection always includes a reference to <HTML>, <HEAD> and <BODY> elements, whether they exist in the document or not.

Properties

length
The length property returns the number of elements in the collection. Note that the length count starts at 1, not 0 as the all collection index does. Therefore, the length property may return a value of 5, but to access the 3rd element, you'd need to use document.all(2).property

Methods

item
The item method retrieves single items, or sub-collections from the all collection. It accepts the following arguments:

all.item(index, sub-index)

If index is a number, then the method returns a reference to the element object at that position in the all collections index. I.e. (using the example above)

strTag=document.all.item(2).tagName

would make strTag be TITLE - the value of the <TITLE> elements tagName property. As you can see, this is effectively the long-hand version of using document.all(2).property.

If the index property is a string value, then the item method returns a sub-collection, containing a reference to every element in the document that has its ID or NAME attribute set to the string contained in the index argument. To retrieve certain element objects from this sub-collection, the sub-index argument must be used. For example, assume that 5 elements in a document all have the NAME attribute set as radColour (these imaginary elements are radio buttons). To interrogate the 3rd of these elements, you could use:

strThird=document.all('radColour',2).propertyName

tags
The tags method returns a collection of element objects whose tagName property is the same as the tag argument used for the method. This differs from the item property in that that interrogates ID and NAME values if necessary.

document.all.tags('EM')

would return a collection of all the <EM> objects in the document.

Questions:


file: /Techref/language/html/ib/Scripting_Reference/allcol.htm, 5KB, , updated: 2008/9/30 15:00, local time: 2024/3/28 09:12,
TOP NEW HELP FIND: 
44.221.46.132:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.ecomorder.com/Techref/language/html/ib/Scripting_Reference/allcol.htm"> The All collection</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .