URL: port プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
値
文字列です。
例
js
// https プロトコルで既定ではないポート番号
new URL("https://example.com:5443/svn/Repos/").port; // '5443'
// http プロトコルで既定ではないポート番号
new URL("http://example.com:8080/svn/Repos/").port; // '8080'
// https プロトコルで既定のポート番号
new URL("https://example.com:443/svn/Repos/").port; // ''(空文字列)
// http プロトコルで既定のポート番号
new URL("http://example.com:80/svn/Repos/").port; // ''(空文字列)
// https プロトコルで明示的なポート番号なし
new URL("https://example.com/svn/Repos/").port; // ''(空文字列)
// http プロトコルで明示的なポート番号なし
new URL("https://example.com/svn/Repos/").port; // ''(空文字列)
// ftp プロトコルで既定ではないポート番号
new URL("ftp://example.com:221/svn/Repos/").port; // '221'
// ftp プロトコルで既定のポート番号
new URL("ftp://example.com:21/svn/Repos/").port; // ''(空文字列)
仕様書
Specification |
---|
URL # dom-url-port |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
port |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
- 所属先の
URL
インターフェイス