blob: 2b7261420d494adfe52c00e78182484769de1a44 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
---
title: document.anchors
slug: Web/API/Document/anchors
translation_of: Web/API/Document/anchors
---
<div>{{APIRef("DOM")}}</div>
<p><code>anchors</code> restituisce un Array contenente tutte le ancore presenti nel documento.</p>
<h3 id="Sintassi" name="Sintassi">Sintassi</h3>
<pre class="eval"><i>nodeList</i> = document.anchors
</pre>
<h3 id="Esempio" name="Esempio">Esempio</h3>
<pre class="eval">if ( document.anchors.length >= 5 ) {
dump("Ho trovato troppe ancore");
window.location = "http<span class="nowiki">:</span>//www.google.com";
}
</pre>
<h3 id="Note" name="Note">Note</h3>
<p>Per ragioni di compatibilità all'indietro, l'array restituito contiene solo le ancore che hanno un attributo <code>name</code> e non quelle che hanno solo l'attributo <code>id</code>.</p>
<h3 id="Specifiche" name="Specifiche">Specifiche</h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7577272">DOM Level 2 HTML: anchors</a></p>
<p>{{ languages( { "ja": "ja/DOM/document.anchors", "pl": "pl/DOM/document.anchors" } ) }}</p>
|