No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

JavaScript : anchor

Information

Deux éléments en JavaScript se rapportent à anchor : la propriété anchors de window.document.anchors, mais aussi String.link.

Warning

Même si ces fonctionnalités sont encore prises en charge par de nombreux navigateurs, elle ne sont plus valides en HTML5.
Il faut à présent utiliser l'attribut id au lieu d'une ancre nommée.

window.document.anchors

Les ancres nommées sont des moyens d'accéder à des parties internes du document.

Propriétés et méthodes

Propriétés 
Propriété | Description |
length | Le nombre de balises <a> contenus dans le document (lecture seule) |
Méthodes 
Méthode | Description |
[index] | Retourne l'élément <a> de la collection anchors à la position spécifiée par index1. |
item(index) | Retourne l'élément <a> de la collection anchors à la position spécifiée par index1. |
namedItem(id) | Retourne l'élément <a> de la collection anchors pour lequel l'id correspond à l'id spécifiée. |

String.prototype.anchor

String chaîne_de_caractères.link(String url);

Retourne le texte de la variable chaîne_de_caractères entourré par une balise HTML représentant une ancre (<a name"nom_de_l_ancre" />).

  1. <script type="text/javascript">
  2. //<![CDATA[
  3. var chaine_de_caracteres="Retour au titre 1";
  4. document.write(chaine.anchor("javascript-anchor"));
  5. //]]>
  6. </script>

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 19/03/2002, last modified the 01/01/1970
Source of the printed document:https://www.gaudry.be/en/javascript-anchor.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

Notes

  1. a,b Index des tableaux JavaScript : Les index des tableaux en JavaScriptcommencent à zéro

Contents Haut