Anchor.name : Anchor « HTML Tags « JavaScript Tutorial






Syntax

document.anchors[num].name

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 tag.

The following example accesses the name Property of the Anchor Object.

<html>
    <a href="#A">A</a>|<a href="#B">B</a>|<a href="#C">C</a>
    <hr><a name="A"><h4>The Letter A</h4></a>
    A<br>
    B<br>
    <hr><a name="B"><h4>The Letter B</h4></a>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    C<br>
    D<br>
    E<br>
    <hr><a name="C"><h4>The Letter C</h4></a>
    F<br>
    G<br>
    <script language="JavaScript">
    <!--
    document.write("<hr>Pick a letter:");
    for(var counter=0; counter<=document.anchors.length; counter++)
    {
      document.write("<a href='#",document.anchors[counter].name,"'>");

      document.write(document.anchors[counter].name,"</a>|");
    }
    -->
    </script>
    </html>








21.2.Anchor
21.2.1.Anchor
21.2.2.Anchor.name
21.2.3.Anchor.text
21.2.4.Anchor.x
21.2.5.Anchor.y