diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
commit | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch) | |
tree | d4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/ca/web/javascript/referencia/objectes_globals/string/link | |
parent | 33058f2b292b3a581333bdfb21b8f671898c5060 (diff) | |
download | translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2 translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip |
initial commit
Diffstat (limited to 'files/ca/web/javascript/referencia/objectes_globals/string/link')
-rw-r--r-- | files/ca/web/javascript/referencia/objectes_globals/string/link/index.html | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/files/ca/web/javascript/referencia/objectes_globals/string/link/index.html b/files/ca/web/javascript/referencia/objectes_globals/string/link/index.html new file mode 100644 index 0000000000..efe1385ddc --- /dev/null +++ b/files/ca/web/javascript/referencia/objectes_globals/string/link/index.html @@ -0,0 +1,119 @@ +--- +title: String.prototype.link() +slug: Web/JavaScript/Referencia/Objectes_globals/String/link +translation_of: Web/JavaScript/Reference/Global_Objects/String/link +--- +<div>{{JSRef}}</div> + +<p>El mètode <strong><code>link()</code></strong> crea un element HTML {{HTMLElement("a")}} que causa que una cadena es mostri com un enllaç hipertext a una altra URL.</p> + +<h2 id="Sintaxi">Sintaxi</h2> + +<pre class="syntaxbox"><code><var>str</var>.link(<var>url</var>)</code></pre> + +<h3 id="Paràmetres">Paràmetres</h3> + +<dl> + <dt><code>url</code></dt> + <dd>Una cadena que especifica l'atribut <code>href</code> de l'etiqueta <code><a>:</code> hauria de ser una URL vàlida (relativa o absoluta), amb qualsevols caràcters escapats <code>&</code> com <code>&amp;</code>, i qualsevol caràcter <code>"</code> escapat com <code>&quot;</code>.</dd> +</dl> + +<h2 id="Descripció">Descripció</h2> + +<p>Use the <code>link()</code> method to create an HTML snippet for a hypertext link. The returned string can then be added to the document via {{domxref("document.write()")}} or {{domxref("element.innerHTML")}}.</p> + +<p>Links created with the <code>link()</code> method become elements in the <code>links</code> array of the <code>document</code> object. See {{domxref("document.links")}}.</p> + +<h2 id="Exemples">Exemples</h2> + +<h3 id="Utilitzar_link()">Utilitzar <code>link()</code></h3> + +<p>L'exemple següent mostra la paraula "MDN" com a un enllaç hypertext lque retorna a l'usuari a la xarxa de Mozilla Developer.</p> + +<pre class="brush: js">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> +</pre> + +<h2 id="Especificacions">Especificacions</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificació</th> + <th scope="col">Estat</th> + <th scope="col">Comentaris</th> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-string.prototype.link', 'String.prototype.link')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Definició inicial. Implementat en JavaScript 1.0. Definit en l'Annex B (normative) per Característiques Addiccionals d'ECMAScript per Navegadors Web.</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Suport bàsic</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("1.0")}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Android</th> + <th>Chrome per Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Suport bàsic</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile("1.0")}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Notes_específiques_Gecko">Notes específiques Gecko</h2> + +<ul> + <li>Starting Gecko 17.0 {{geckoRelease("17")}} the <code>"</code> (quotation mark) is now automatically replaced by its HTML reference character <code>&quot;</code> in the <code>url</code> parameter.</li> +</ul> + +<h2 id="Vegeu_també">Vegeu també</h2> + +<ul> + <li>{{jsxref("String.prototype.anchor()")}}</li> +</ul> |