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/hostname/index.html | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 files/zh-cn/web/api/location/hostname/index.html (limited to 'files/zh-cn/web/api/location/hostname') diff --git a/files/zh-cn/web/api/location/hostname/index.html b/files/zh-cn/web/api/location/hostname/index.html new file mode 100644 index 0000000000..20c424dcdf --- /dev/null +++ b/files/zh-cn/web/api/location/hostname/index.html @@ -0,0 +1,43 @@ +--- +title: 'Location: hostname' +slug: Web/API/Location/hostname +translation_of: Web/API/Location/hostname +--- +

{{ApiRef("URL API")}}

+ +

{{domxref("Location")}}的 hostname 属性是包含了域名的一段 {{domxref("USVString")}}。

+ +

Syntax

+ +
string = object.hostname;
+object.hostname = string;
+
+ +

Examples

+ +
// 在文档流中声明了一个元素: <a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location.hostname">
+var anchor = document.getElementById("myAnchor");
+var result = anchor.hostname; // Returns:'developer.mozilla.org'
+ +

Specifications

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

Browser compatibility

+ + + +

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

-- cgit v1.2.3-54-g00ecf