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 : link

Information

Deux éléments en JavaScript se rapportent à link. Je parlerai principalement ici de la propriété links de window.document.links, mais j'évoquerai aussi le prototype de string : String.link.

De la même manière que la balise <a> en langage HTML, l'objet link nous permet de lier des documents, fichiers, ou autres, au document en cours. Les différents liens d'un document se présentent sous forme de tableau, ce qui nous permet l'utilisation de leur index dans les références :

document.links[numéro_index].nom_propriété

Propriétés et méthodes

Propriétés 
Méthodes 

Si nous désirons que le click sur un lien ne renvoie pas une URL, mais exécute plutôt un script, nous devons utiliser la syntaxe suivante 

javascript:nom_méthode();

C'est particulièrement pratique pour, par exemple, modifier plusieurs cadres (frames) d'une seule action.


Codes HTML, JavaScript, HTML  (18 lignes) :
  1.  
  1.  
  2. <script type="text/javascript">
  3. //<![CDATA[
  4. function ouvre_double_fenetre(url1, url2){
  5. parent.nom_frame1.location.href=url1;
  6. parent.nom_frame2.location.href=url2;
  7. }
  8. //]]>
  9. </script>
  1.  
  2. </head>
  3. <a href="javascript:ouvre_double_fenetre('page1.html', 'page2.html');">Cliquez ici</a>
  4. </body>
  5. </html>

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 permettant un lien.

  1. <script type="text/javascript">
  2. //<![CDATA[
  3. var chaine_de_caracteres="Accueil du site";
  4. document.write(chaine.link("https://www.gaudry.be/en/"));
  5. //]]>
  6. </script>

Warning

Même si cette fonctionnalité est encore prise en charge par de nombreux navigateurs, elle n'est plus reprise dans les standards du Web.

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