URL: origin プロパティ
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.
origin
は URL
インターフェイスの読み取り専用プロパティで、表現された URL のオリジンを Unicode シリアル化したものが入った文字列を返します。
正確な構造は、次のように URL の種類によって異なります。
http
またはhttps
の URL の場合、スキームの後に'://'
、ドメイン、':'
、ポート番号が順に続きます(ポート番号は、明示的に指定されており、それが既定のポート、それぞれ80
と443
でないときに現れます)。file:
URL の場合、値はブラウザーに依存します。blob:
URL の場合、blob:
に続く URL のオリジンが使用されます。 例えば、"blob:https://mozilla.org"
は"https://mozilla.org"
として返されます。
メモ: この機能はウェブワーカー内で利用可能です。
値
文字列です。
例
js
const url = new URL("blob:https://mozilla.org:443/");
console.log(url.origin); // 'https://mozilla.org' とログ出力
const url = new URL("http://localhost:80/");
console.log(url.origin); // 'http://localhost' とログ出力
const url = new URL("https://mozilla.org:8080/");
console.log(url.origin); // 'https://mozilla.org:8080' とログ出力
仕様書
Specification |
---|
URL # dom-url-origin |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
origin |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Has more compatibility info.
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
インターフェイス