HTMLAreaElement: host 屬性
HTMLAreaElement 介面的 host 屬性是一個字串,包含主機名。它由 hostname 組成,如果 URL 的 埠非空,則後面跟著一個 ":",最後是 URL 的 port。如果 URL 沒有 hostname,則該屬性包含一個空字串 ""。
有關詳細資訊,請參閱 URL.host。
值
字串。
示例
js
const area = document.createElement("area");
area.href = "https://mdn.club.tw/en-US/HTMLAreaElement";
area.host === "developer.mozilla.org";
area.href = "https://mdn.club.tw:443/en-US/HTMLAreaElement";
area.host === "developer.mozilla.org";
// The port number is not included because 443 is the scheme's default port
area.href = "https://mdn.club.tw:4097/en-US/HTMLAreaElement";
area.host === "developer.mozilla.org:4097";
規範
| 規範 |
|---|
| HTML # dom-hyperlink-host-dev |
瀏覽器相容性
載入中…
另見
- 它所屬的
HTMLAreaElement介面。