The location object contains information about the current URL.
The location object is part of the window object and is accessed through the window.location property.
Property | Description |
---|---|
hash | Sets or gets the anchor part (#) of a URL |
host | Sets or gets the hostname and port number of a URL |
hostname | Sets or gets the hostname of a URL |
href | Sets or gets the URL |
origin | Returns the protocol, hostname and port number of a URL |
pathname | Sets or gets the path name of a URL |
port | Sets or gets the port number of a URL |
protocol | Sets or gets the protocol of a URL |
search | Sets or gets the query string of a URL |
Method | Description |
---|---|
assign() | Loads a new document |
reload() | Reloads the current document |
replace() | Replaces the current document with a new one |