The anchor property (Array)

The anchor property is actually an array set by the browser for all the named anchors in the document.

In JavaScript, the lenght property allows you to find how many named anchors there are on the page.

<body>
<h1>The anchor property</h1>

<a name="anchor1"></a>
<h2>Honda motorcycles</h2>
<p>This paragraph talks about Honda motorbikes.</p>

<a name="anchor2"></a>
<h2>Yamaha motorcycles</h2>
<p>This paragraph talks about Yamaha motorbikes.</p>

<a name="anchor3"></a>
<h2>Suzuki motorcycles</h2>
<p>This paragraph talks about Suzuki motorbikes.</p>

<script type="text/javascript">
document.write("There are " + document.anchors.length + " named anchors on this page.");
</script>
</body>

Leave a Reply