home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Anchor Object

Name

Anchor Object---the target of a hypertext link

Availability

Implemented but nonfunctional in Navigator 2.0, 3.0, and Internet Explorer 3.0

Synopsis

document.anchors.length
document.anchors[i]

HTML Syntax

An Anchor object is created by any standard HTML <A> tag that contains a <NAME> attribute:

<A
  NAME="anchor_name"  links may refer to this anchor by this name
  [ HREF=URL ]    an anchor may also be a link
  [ TARGET="window_name" ]    links may refer to other windows
>
link text
</A>

Description

An "anchor" is a named location within an HTML document. Anchors are created with the NAME attribute of the <A> tag. The JavaScript Document object has an anchors[] array property that should contain references to each of the anchors in the document. Unfortunately, in Navigator 2.0 and 3.0 and in Internet Explorer 3.0, the elements of this array always contain null. The problem is that the Anchor object has not yet been implemented. A future version of the language should contain an actual working Anchor object, and the anchors[] array will be filled in with references to appropriate Anchor objects.

Note that the <A> tag used to create anchors is also used to create hypertext links. Although hypertext links are often called "anchors" in HTML parlance, they are represented in JavaScript with the Link object, not with the Anchor object.


Previous Home Next
alert() Book Index Applet

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell