URL: origin-Eigenschaft
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.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die schreibgeschützte origin
-Eigenschaft des URL
-Interfaces gibt einen String zurück, der die Unicode-Serialisierung des Ursprungs der repräsentierten URL enthält.
Die genaue Struktur variiert je nach Typ der URL:
- Für URLs mit den Schemas
ftp:
,http:
,https:
,ws:
undwss:
wird dasprotocol
, gefolgt von//
und anschließend demhost
, zurückgegeben. Wie beihost
wird derport
nur einbezogen, wenn er nicht der Standardwert für das Protokoll ist. - Für URLs mit dem Schema
file:
ist der Wert vom Browser abhängig. - Für URLs mit dem Schema
blob:
ist der Ursprung die URL, die demblob:
folgt, jedoch nur, wenn diese URL das Schemahttp:
,https:
oderfile:
verwendet. Zum Beispiel hatblob:https://mozilla.org
den Ursprunghttps://mozilla.org
.
In allen anderen Fällen wird der String "null"
zurückgegeben.
Wert
Ein String.
Beispiele
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'
Spezifikationen
Specification |
---|
URL # dom-url-origin |
Browser-Kompatibilität
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.