The host
property of the URL
interface is a string containing the host, that is the hostname
, and then, if the port of the URL is nonempty, a ':'
, followed by the port
of the URL.
Note: This feature is available in Web Workers
The host
property of the URL
interface is a string containing the host, that is the hostname
, and then, if the port of the URL is nonempty, a ':'
, followed by the port
of the URL.
Note: This feature is available in Web Workers
A string.
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"
Specification |
---|
URL Standard # dom-url-host |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
host |
32 | 13 | 22 | No | 19 | 7 | 4.4.3 | 32 | 22 | 19 | 7 | 2.0 |
URL
interface it belongs to.
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/URL/host