aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/api/url/host/index.html
blob: f18934e6a6827d1ef75d1ae50f87f384d30b6a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
title: Estabilidad
slug: Web/API/URL/Host
translation_of: Web/API/URL/host
---
<div>{{ApiRef("URL API")}}</div>

<p>The <strong><code>host</code></strong> property of the {{domxref("URL")}} interface is a {{domxref("USVString")}} containing the host, that is the {{domxref("URL.hostname", "hostname")}}, and then, if the {{glossary("port")}} of the URL is nonempty, a <code>':'</code>, followed by the {{domxref("URL.port", "port")}} of the URL.</p>

<p>{{AvailableInWorkers}}</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">const <em>host</em> = <em>url</em>.host
<em>url.<code>host</code></em> = <em>newHost</em>
</pre>

<h3 id="Value">Value</h3>

<p>A {{domxref("USVString")}}.</p>

<h2 id="Examples">Examples</h2>

<pre class="brush: js">let url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/host');
console.log(url.host); // "developer.mozilla.org"

url = new URL('https://developer.mozilla.org:443/en-US/docs/Web/API/URL/host');
console.log(url.host); // "developer.mozilla.org"
// The port number is not included because 443 is the scheme's default port

url = new URL('https://developer.mozilla.org:4097/en-US/docs/Web/API/URL/host');
console.log(url.host); // "developer.mozilla.org:4097"
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('URL', '#dom-url-host', 'URL.host')}}</td>
   <td>{{Spec2('URL')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("api.URL.host")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>The {{domxref("URL")}} interface it belongs to.</li>
</ul>