[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/API/Location [Back]  [Original]

Location - Web API | MDN

MDN Web Docs

View in English Always switch to English

Location

Baseline *

20157

*

Location (URL) Document Window Location Document.location Window.location

Location

URL

Location.ancestorOrigins

DOMStringList Location

Location.href

URL

Location.protocol

':' URL

Location.host

URL (':')

Location.hostname

URL

Location.port

URL

Location.pathname

URL '/' URL

Location.search

URL '?' URLSearchParams URL.searchParams

Location.hash

URL '#'

Location.origin

Location.assign()

URL

Location.reload()

URL

Location.replace()

URL assign() replace() History

Location.toString()

URL Location.href

js
// location: https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container
const loc = document.location;
console.log(loc.href); // https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container
console.log(loc.protocol); // https:
console.log(loc.host); // developer.mozilla.org:8080
console.log(loc.hostname); // developer.mozilla.org
console.log(loc.port); // 8080
console.log(loc.pathname); // /en-US/search
console.log(loc.search); // ?q=URL
console.log(loc.hash); // #search-results-close-container
console.log(loc.origin); // https://developer.mozilla.org:8080

location.assign("http://another.site"); // load another page

HTML
# the-location-interface


Web Proxy Viewer  |  New URL  |  Original Page