Document.anchors[] (Collection)

An array of all the anchor objects in the document.

Availability:

DOM level - 1
JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Opera - 5.0
Property/method value type:AnchorArray object
JavaScript syntax:-myDocument.anchors
HTML syntax:<A>

There is one anchor object for every<A> HTML tag in the page.

Prior to version 1.2 of JavaScript, this array simply contained a list of anchors but there were no anchor objects accessible until Netscape 4 implemented them. The only property that could be accessed prior to that was the length of the array.

Changing the name of an anchor in MSIE leaves the existing anchor available and adds a copy using the new name. This may be important if you are parsing the anchors array with an enumerator.

Refer to the description of the AnchorArray object for details of how it enhances the built-in Array class.

There is some difference between the browsers in the way they implementanchor and linkobjects. In MSIE the anchor and link objects are represented identically and the objects simply ignore properties they don't need. Netscape supports different objects according to whether they are links or anchors.

DOM level 1 requires that this collection contains only those objects instantiated by an <A> HTML tag which contain a NAME="..." HTML tag attribute. Any anchors that have an ID="..." HTML tag attribute but no NAME="..." attribute should not be included.

Warnings:

See also:Anchor object, Anchor.name, AnchorArray object, AnchorArray.length, Document object, Document.links[], Element.all[], LINK object, LinkArray object

Property attributes:

ReadOnly