JavaScript » Document » anchors

Syntax:
document.anchors["anchorID" ]

This property is an array containing references to all the named Anchor objects in the current document.

This property is an array containing references to all the named Anchor objects in the current document. These references are stored in the array in the order in which they are defined in the source code. The "anchorID" argument is used to access items in the array and this can either be a string containing the anchor name as defined within the <A></A> tags in the HTML source, or an integer (with '0' being the first item in the array).

Both examples below return the same results; the first uses the defined names of the anchors and the second uses their reference number within the array.

Examples

Code:
// alt 1
document.anchors("anchorname1")
document.anchors("anchorname2")
document.anchors("anchorname3")

// alt 2
document.anchors[0]
document.anchors[1]
document.anchors[2]
Explanation:

Both alternatives in the example return the same results; the first uses the defined names of the anchors and the second uses their reference number within the array.