Anchor Objects
Anchor Objects
Syntax
document.anchor[n]
document.anchor.length
Description
When your page is displayed to a reader, the anchors array
creates an element for each anchor in the page. The first
anchor is anchor[0], the next is anchor[1], and so forth.
The anchors.length value reflects the number of items in
the array.
The actual name of the anchor is always null. That is, you
cannot use the anchors array to discover an anchor's
name. You also cannot create an anchor programatically.
For example, the statement anchor[0]="hello" does
nothing.
The anchor object is a property of the larger document
object.
Example
The custom function in the following listing returns true if
the current page has at least one anchor in it. It returns
false if the page contains no anchors.
function hasAnchors() {
retval = true
if (document.anchors.length == 0) {
retval = false
} return retval
}