For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Interface Location

The Location interface represents the location (URL) of the object it is linked to.

MDN Reference

interface Location {
    ancestorOrigins: DOMStringList;
    hash: string;
    host: string;
    hostname: string;
    href: string;
    origin: string;
    pathname: string;
    port: string;
    protocol: string;
    search: string;
    assign(url: string | URL): void;
    reload(): void;
    replace(url: string | URL): void;
    toString(): string;
}
Index

Properties

ancestorOrigins: DOMStringList

The ancestorOrigins read-only property of the Location interface is a static browsing contexts of the document associated with the given Location object.

MDN Reference

hash: string

The hash property of the Location interface is a string containing a '#' followed by the fragment identifier of the location URL.

MDN Reference

host: string

The host property of the Location interface is a string containing the host, which is the Location.hostname, and then, if the port of the URL is nonempty, a ':', followed by the Location.port of the URL.

MDN Reference

hostname: string

The hostname property of the Location interface is a string containing either the domain name or IP address of the location URL.

MDN Reference

href: string

The href property of the Location interface is a stringifier that returns a string containing the whole URL, and allows the href to be updated.

MDN Reference

origin: string

The origin read-only property of the Location interface returns a string containing the Unicode serialization of the origin of the location's URL.

MDN Reference

pathname: string

The pathname property of the Location interface is a string containing the path of the URL for the location.

MDN Reference

port: string

The port property of the Location interface is a string containing the port number of the location's URL.

MDN Reference

protocol: string

The protocol property of the Location interface is a string containing the protocol or scheme of the location's URL, including the final ':'.

MDN Reference

search: string

The search property of the Location interface is a search string, also called a query string, that is a string containing a '?' followed by the parameters of the location's URL.

MDN Reference

Methods

  • The assign() method of the Location interface causes the window to load and display the document at the URL specified.

    MDN Reference

    Parameters

    • url: string | URL

    Returns void

  • The reload() method of the Location interface reloads the current URL, like the Refresh button.

    MDN Reference

    Returns void

  • The replace() method of the Location interface replaces the current resource with the one at the provided URL.

    MDN Reference

    Parameters

    • url: string | URL

    Returns void

  • Returns string

Was this helpful?