MDN self-hosted library · e01.org

URL: origin property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const url = new URL("blob:https://mozilla.org:443/");
console.log(url.origin); // 'https://mozilla.org'
js
const url = new URL("http://localhost:80/");
console.log(url.origin); // 'http://localhost'
js
const url = new URL("https://mozilla.org:8080/");
console.log(url.origin); // 'https://mozilla.org:8080'