From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/location/host/index.html | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 files/zh-cn/web/api/location/host/index.html (limited to 'files/zh-cn/web/api/location/host') diff --git a/files/zh-cn/web/api/location/host/index.html b/files/zh-cn/web/api/location/host/index.html new file mode 100644 index 0000000000..f4ab84da3d --- /dev/null +++ b/files/zh-cn/web/api/location/host/index.html @@ -0,0 +1,52 @@ +--- +title: 'Location: host' +slug: Web/API/Location/host +translation_of: Web/API/Location/host +--- +
{{ApiRef("Location")}}
+ +

{{domxref("Location")}} 接口的 host 属性是包含了主机的一段 {{domxref("USVString")}},其中包含:主机名,如果 URL 的端口号是非空的,还会跟上一个 ':' ,最后是 URL 的端口号。

+ +

Syntax

+ +
string = object.host;
+object.host = string;
+
+ +

Examples

+ +
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

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#dom-location-host', 'host')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

Browser compatibility

+ + + +

{{Compat("api.Location.host")}}

-- cgit v1.2.3-54-g00ecf