English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Location Object

The Location object represents the position of the current URL (URL).

The Location object iswindow (Window)Part of an object that can be written without a window prefix.

Location Object Properties

The following table lists the properties of the Location object:

PropertyDescription
hashSet or return the anchoring part (#[hash]) of the URL
hostSet or return the hostname and port number of the URL
hostnameSet or return the hostname of the URL
hrefSet or return the entire URL
originReturn the protocol, hostname, and port number of the URL
pathnameSet or return the pathname of the URL
portSet or return the port number of the URL
protocolSet or return the protocol of the URL
searchSet or return the querystring part of the URL

Location Object Methods

The following table lists the methods of the Location object:

MethodDescription
assign()Load resources on the URL provided in the parameters
reload()Reload the resource from the current URL
replace()Replace the current resource with the resource provided in the URL