Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Document
  4. location

Document: location property

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⁩.

The read-onlylocation property of theDocument interface returns aLocation object, which contains information about the URL of the document and provides methods for changing that URL and loading another URL.

To retrieve just the URL as a string, the read-onlydocument.URLproperty can also be used.

Value

ALocation object. If the current document is not in a browsing context, the returned value isnull.

Although thelocation property itself is read-only in the sense that you can't replace theLocation object, you can still assign to thelocation property directly, which is equivalent to assigning to itshref property. You can also modify theLocation object using theassign() andreplace() methods.

Examples

js
console.log(document.location);// Prints a Location object to the console

Specifications

Specification
HTML
# the-location-interface

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp