The Location represents the location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Location object accessible via document.location, window.location or variable location.


property description
href String that containing the whole URL.
 // goto to home link
protocol The protocol scheme of the URL, including the final ':'.
host The host, that is the hostname, a ':', and the port of the URL.
port The port number of the URL.
pathname String that containing an initial '/' followed by the path of the URL.
search String that contains a '?' followed by the parameters or "querystring" of the URL. Modern browsers provide URLSearchParams and URL.searchParams to make it easy to parse out the parameters from the querystring.
hash String that contains containing a '#' followed by the fragment identifier of the URL.
username The username specified before the domain name.
password The password specified before the domain name.


method description
reload(nocache) Reloads the current URL, like the Refresh button.
  • nocache - optional parameter; if false or unspecified, the browser may reload the page from its HTTP cache
assign(url) Loads and displays the document at the URL specified.