interface Location

The location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Accessible via globalThis.location.

Properties

Returns a DOMStringList object listing the origins of the ancestor browsing contexts, from the parent browsing context to the top-level browsing context.

Always empty.

hash: string

Returns the Location object's URL's fragment (includes leading "#" if non-empty).

Cannot be set.

host: string

Returns the Location object's URL's host and port (if different from the default port for the scheme).

Cannot be set.

hostname: string

Returns the Location object's URL's host.

Cannot be set.

href: string

Returns the Location object's URL.

Cannot be set.

readonly
origin: string

Returns the Location object's URL's origin.

pathname: string

Returns the Location object's URL's path.

Cannot be set.

port: string

Returns the Location object's URL's port.

Cannot be set.

protocol: string

Returns the Location object's URL's scheme.

Cannot be set.

Methods

toString(): string
assign(url: string): void

Navigates to the given URL.

Cannot be set.

reload(): void

Reloads the current page. Disabled.

deprecated
reload(forcedReload: boolean): void
replace(url: string): void

Removes the current page from the session history and navigates to the given URL. Disabled.

variable Location

The location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Accessible via globalThis.location.

Properties