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

JavaScript: The Definitive Guide

Previous Chapter 14
Documents and Their Contents

14.3 The Anchor Object

Just as a Link object represents a hypertext link, an Anchor object represents a named location within a document which can serve as the target of a hypertext link. Anchors are something like the reverse of Links, and they are treated similarly to Links in HTML and in JavaScript. An anchor is created with the <A> tag, when it is used with the NAME attribute (rather than the HREF attribute, which creates a link). The Document object contains an anchors[] property which is an array of all the Anchors in the document.

There is only one flaw in this analogy between links and anchors: the Anchor object has not been implemented in either JavaScript 1.0 or JavaScript 1.1. So, in Navigator 2.0, Navigator 3.0, and Internet Explorer 3.0, the anchors[] property of the Document object is an array that contains null for each of its elements. The length property of the anchors[] array does work, and you can use it to determine the number of anchors in a given document, although this information may not be of particular use.

The next version of JavaScript will likely contain a useful implementation of the Anchor object.

Previous Home Next
The Link Object Book Index The JavaObject Object

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