diff options
Diffstat (limited to 'files/fr/web/api/location/index.html')
-rw-r--r-- | files/fr/web/api/location/index.html | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/files/fr/web/api/location/index.html b/files/fr/web/api/location/index.html index 52372c8da1..dc4e6e6a36 100644 --- a/files/fr/web/api/location/index.html +++ b/files/fr/web/api/location/index.html @@ -77,7 +77,7 @@ body {display:table-cell; text-align:center; vertical-align:middle; font-family: <dt>{{domxref("Location.pathname")}}</dt> <dd>Une {{domxref("DOMString")}} contenant un <code>'/'</code> initial suivi du chemin de l'URL.</dd> <dt>{{domxref("Location.search")}}</dt> - <dd>Une {{domxref("DOMString")}} contenant un <code>'?'</code> suivi des paramètres de l'URL. Les navigateurs moderne fournissent <a href="/en-US/docs/Web/API/URLSearchParams/get#Example">URLSearchParams</a> et <a href="/en-US/docs/Web/API/URL/searchParams#Example">URL.searchParams</a> <span class="tlid-translation translation" lang="fr"><span title="">pour faciliter l'analyse des paramètres</span></span> de la <span class="tlid-translation translation" lang="fr"><span title="">chaîne de requête (querystring).</span></span></dd> + <dd>Une {{domxref("DOMString")}} contenant un <code>'?'</code> suivi des paramètres de l'URL. Les navigateurs moderne fournissent <a href="/en-US/docs/Web/API/URLSearchParams/get#Example">URLSearchParams</a> et <a href="/en-US/docs/Web/API/URL/searchParams#Example">URL.searchParams</a> pour faciliter l'analyse des paramètres de la chaîne de requête (querystring).</dd> <dt>{{domxref("Location.hash")}}</dt> <dd>Une {{domxref("DOMString")}} contenant un <code>'#'</code> suivi de <em>l'identifiant de fragment</em> de l'URL.</dd> <dt>{{domxref("Location.username")}} {{Obsolete_Inline}}</dt> @@ -105,19 +105,19 @@ body {display:table-cell; text-align:center; vertical-align:middle; font-family: <h2 id="Exemples">Exemples</h2> -<pre class="brush: js line-numbers language-js"><code class="language-js">// Crée un élèment ancre et utilise la propriété href </code>dans le but de cet exemple -<code class="language-js">// </code>Une alternative plus correcte est de naviguer vers l'URL et d'utiliser document.location ou window.location -<code class="language-js"><span class="keyword token">var</span> url <span class="operator token">=</span> document<span class="punctuation token">.</span><span class="function token">createElement</span><span class="punctuation token">(</span><span class="string token">'a'</span><span class="punctuation token">)</span><span class="punctuation token">;</span> -url<span class="punctuation token">.</span>href <span class="operator token">=</span> <span class="string token">'https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container'</span><span class="punctuation token">;</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>href<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>protocol<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// https:</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>host<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// developer.mozilla.org:8080</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>hostname<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// developer.mozilla.org</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>port<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// 8080</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>pathname<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// /en-US/search</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>search<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// ?q=URL</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>hash<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// #search-results-close-container</span> -console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>url<span class="punctuation token">.</span>origin<span class="punctuation token">)</span><span class="punctuation token">;</span> <span class="comment token">// https://developer.mozilla.org:8080</span></code></pre> +<pre class="brush: js">// Crée un élèment ancre et utilise la propriété href dans le but de cet exemple +// Une alternative plus correcte est de naviguer vers l'URL et d'utiliser document.location ou window.location +var url = document.createElement('a'); +url.href = 'https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container'; +console.log(url.href); // https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container +console.log(url.protocol); // https: +console.log(url.host); // developer.mozilla.org:8080 +console.log(url.hostname); // developer.mozilla.org +console.log(url.port); // 8080 +console.log(url.pathname); // /en-US/search +console.log(url.search); // ?q=URL +console.log(url.hash); // #search-results-close-container +console.log(url.origin); // https://developer.mozilla.org:8080</pre> <h2 id="Spécifications">Spécifications</h2> |