aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/location/host/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/location/host/index.html')
-rw-r--r--files/zh-cn/web/api/location/host/index.html52
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>