Anchor.name

JavaScript 1.2+, JScript 3.0+ Nav4+, IE 4+ Syntax

document.anchors[num].name

Description

The name property holds the name of the anchor and is the way hyperlinks reference the anchor's position. This property is originally set by the NAME attribute in the <a> tag.

Example

Listing 7.2 creates a dictionary of fruit where the heading for each letter of the dictionary is designated as an anchor. At the bottom of the document, the name property of each anchor is used to create the hyperlink text and reference each anchor.

Listing 7.2 Accessing the name Property of the Anchor Object
 <html> <center> <h1><u>Fruit Dictionary</u></h1> Pick a letter: <a href="#A">A</a>|<a href="#B">B</a>|<a href="#C">C</a> </center> <hr><a name="A"><h4>The ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.