HTMLAreaElement: host 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

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

瀏覽器相容性

另見