HTMLAreaElement: port 属性
HTMLAreaElement 接口的 port 属性是一个字符串,包含 <area> 元素 href 的端口号。如果端口是协议的默认端口(ws: 和 http: 为 80,wss: 和 https: 为 443,ftp: 为 21),则此属性包含一个空字符串 ""。
可以设置此属性来更改 URL 的端口。如果 URL 没有 host 或其方案是 file:,则设置此属性无效。它还会默默忽略无效的端口号。
有关更多信息,请参阅 URL.port。
值
字符串。
示例
从 area 链接获取端口
js
// An <area id="myArea" href="https://mdn.org.cn:443/en-US/docs/HTMLAreaElement"> element is in the document
const area = document.getElementByID("myArea");
area.port; // Returns ''
js
// Another <area id="myArea" href="https://mdn.org.cn:8888/en-US/docs/HTMLAreaElement"> element is in the document
const area = document.getElementByID("myArea");
area.port; // Returns:'8888'
规范
| 规范 | 
|---|
| HTML # dom-hyperlink-port-dev | 
浏览器兼容性
加载中…
另见
- 它所属的 HTMLAreaElement接口。