HTMLAreaElement: host 属性
HTMLAreaElement 接口的 host 属性是一个字符串,包含主机名。它由 hostname 组成,如果 URL 的 端口非空,则后面跟着一个 ":",最后是 URL 的 port。如果 URL 没有 hostname,则该属性包含一个空字符串 ""。
有关详细信息,请参阅 URL.host。
值
字符串。
示例
js
const area = document.createElement("area");
area.href = "https://mdn.org.cn/en-US/HTMLAreaElement";
area.host === "developer.mozilla.org";
area.href = "https://mdn.org.cn: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.org.cn:4097/en-US/HTMLAreaElement";
area.host === "developer.mozilla.org:4097";
规范
| 规范 |
|---|
| HTML # dom-hyperlink-host-dev |
浏览器兼容性
加载中…
另见
- 它所属的
HTMLAreaElement接口。