URL.port

URL 接口的端口属性是包含了URL的端口号信息的USVString值,如果URL中不包含明确的端口号,这个属性将为''.
Note: 此特性在 Web Worker 中可用。

语法

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

参数

A USVString.

示例

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

规范

规范 状态 备注
URL
URL.port
Living Standard Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
portChrome Full support YesEdge Full support 13Firefox Full support 22IE ? Opera Full support YesSafari Full support 10WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 22Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

相关链接

  • The URL interface it belongs to.