A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/URL/host below:

URL: host property - Web APIs

URL: host property

Baseline Widely available

Note: This feature is available in Web Workers.

The host property of the URL interface is a string containing the host, which is the hostname, and then, if the port of the URL is nonempty, a ":", followed by the port of the URL. If the URL does not have a hostname, this property contains an empty string, "".

This property can be set to change both the hostname and the port of the URL. If the URL's scheme is not hierarchical (which the URL standard calls "special schemes"), then it has no concept of a host and setting this property has no effect.

Note: If the given value for the host setter lacks a port, the URL's port will not change. This can be unexpected as the host getter does return a URL-port string, so one might have assumed the setter to always "reset" both.

Value

A string.

Examples
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"
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3