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.

originURL インターフェイスの読み取り専用プロパティで、表現された URL のオリジンを Unicode シリアル化したものが入った文字列を返します。

正確な構造は、次のように URL の種類によって異なります。

  • http または https の URL の場合、スキームの後に '://'、ドメイン、':'、ポート番号が順に続きます(ポート番号は、明示的に指定されており、それが既定のポート、それぞれ80443 でないときに現れます)。
  • 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 GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
origin

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Has more compatibility info.

関連情報

  • 所属先の URL インターフェイス