Location: host
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Syntax
string = object.host; object.host = string;
Examples
js
var anchor = document.createElement("a");
anchor.href = "https://developer.mozilla.org/en-US/Location.host";
anchor.host == "developer.mozilla.org";
anchor.href = "https://developer.mozilla.org:443/en-US/Location.host";
anchor.host == "developer.mozilla.org";
// 这里 host 中没有包含端口号,因为 443 是 https 协议的默认端口号
anchor.href = "https://developer.mozilla.org:4097/en-US/Location.host";
anchor.host == "developer.mozilla.org:4097";
Specifications
Specification |
---|
HTML # dom-location-host-dev |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
host |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.