URL.port

URL 接口的端口属性是包含了 URL 的端口号信息的USVString值,如果 URL 中不包含明确的端口号,这个属性将为''.

备注: 此特性在 Web Worker 中可用。

语法

string = object.port;
object.port = string;

参数

示例

js
var url = new URL("https://mydomain.com:80/svn/Repos/");
var result = url.port; // Returns:'80'

规范

Specification
URL Standard
# dom-url-port

浏览器兼容性

BCD tables only load in the browser

参见

  • The URL interface it belongs to.