diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/location/host | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/location/host')
-rw-r--r-- | files/zh-cn/web/api/location/host/index.html | 52 |
1 files changed, 52 insertions, 0 deletions
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 +--- +<div>{{ApiRef("Location")}}</div> + +<p>{{domxref("Location")}} 接口的 <strong><code>host</code></strong> 属性是包含了主机的一段 {{domxref("USVString")}},其中包含:主机名,如果 URL 的端口号是非空的,还会跟上一个 <code>':'</code> ,最后是 URL 的端口号。</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.host; +<em>object.<code>host</code></em> = <em>string</em>; +</pre> + +<h2 id="Examples">Examples</h2> + +<pre class="brush: js notranslate">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" +// 这里 <code>host </code>中没有包含端口号,因为 443 是 https协议的默认端口号 + +anchor.href = "https://developer.mozilla.org:4097/en-US/Location.host" +anchor.host == "developer.mozilla.org:4097" +</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', '#dom-location-host', 'host')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.Location.host")}}</p> |