Location class

Location class

Location objects provide a representation of the address of the active document of their Document’s browsing context, and allow the current entry of the browsing context’s session history to be changed, by adding or replacing entries in the history object.

Inheritance: LocationDOMObject

The Location type exposes the following members:

Properties

PropertyDescription
hrefReturns the Location object’s URL.
Can be set, to navigate to the given URL.
originReturns the Location object’s URL’s origin.
protocolReturns the Location object’s URL’s scheme.
Can be set, to navigate to the same URL with a changed scheme.
hostReturns the Location object’s URL’s host and port (if different from the default port for the scheme).
Can be set, to navigate to the same URL with a changed host and port.
hostnameReturns the Location object’s URL’s host.
Can be set, to navigate to the same URL with a changed host.
portReturns the Location object’s URL’s port.
Can be set, to navigate to the same URL with a changed port.
pathnameReturns the Location object’s URL’s path.
Can be set, to navigate to the same URL with a changed path.
searchReturns the Location object’s URL’s query (includes leading “?” if non-empty).
Can be set, to navigate to the same URL with a changed query(ignores leading “?”).
hashReturns the Location object’s URL’s fragment (includes leading “#” if non-empty).
Can be set, to navigate to the same URL with a changed fragment(ignores leading “#”).

Methods

MethodDescription
get_platform_typeThis method is used to retrieve ECMAScript object Type.
assignNavigates to the given page.
replaceRemoves the current page from the session history and navigates to the given page.
reloadReloads the current page.

See Also