We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

This translation is incomplete. Please help translate this article from English.

El mètode link() crea un element HTML <a> que causa que una cadena es mostri com un enllaç hipertext a una altra URL.




Una cadena que especifica l'atribut href de l'etiqueta <a>: hauria de ser una URL vàlida (relativa o absoluta), amb qualsevols caràcters escapats & com &amp;, i qualsevol caràcter "  escapat com &quot;.


Use the link() method to create an HTML snippet for a hypertext link. The returned string can then be added to the document via document.write() or element.innerHTML.

Links created with the link() method become elements in the links array of the document object. See document.links.


Utilitzar link()

L'exemple següent mostra la paraula "MDN" com a un enllaç hypertext lque retorna a l'usuari a la xarxa de Mozilla Developer.

var hotText = 'MDN';
var URL = 'https://developer.mozilla.org/';

console.log('Click to return to ' + hotText.link(URL));
// Click to return to <a href="https://developer.mozilla.org/">MDN</a>


Especificació Estat Comentaris
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'String.prototype.link' in that specification.
Standard Definició inicial. Implementat en JavaScript 1.0. Definit en l'Annex B (normative) per Característiques Addiccionals d'ECMAScript per Navegadors Web.

Compatibilitat amb navegadors

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Suport bàsic (Yes) 1.0 (1.7 or earlier) (Yes) (Yes) (Yes)
Característica Android Chrome per Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suport bàsic (Yes) (Yes) 1.0 (1.0) (Yes) (Yes) (Yes)

Notes específiques Gecko

  • Starting Gecko 17.0 (Firefox 17 / Thunderbird 17 / SeaMonkey 2.14) the " (quotation mark) is now automatically replaced by its HTML reference character &quot; in the url parameter.

Vegeu també

Document Tags and Contributors

Contributors to this page: llue
Last updated by: llue,