Location Object
Location object
The Location object contains information about the current URL.
The Location object is part of the window object, it can be accessed through related properties in the format window.location.xxx .
Note: There is no published standard that applies to the Location object, but it is supported by all browsers.
Location Object Properties
Property | Description |
---|---|
hash | Returns the anchor portion of a URL |
host | Returns the hostname and port of a URL |
hostname | Returns the hostname of the URL |
href | Returns the full URL |
pathname | Returns the URL pathname. |
port | Returns the port number used by a URL server |
protocol | returns a URL protocol |
search | Returns the query part of a URL |
Location Object Methods
Method | Description |
---|---|
assign() | Load a new document |
reload() | Reload current document |
replace() | Replace the current document with the new document |