Location object
Location Object
The Location object contains information about the current URL.
The Location object is part of the window object and can be accessed through the window.Location property.
Note: There is no public standard for Location objects, but all browsers support this object.
Location Object Properties
Properties | Description |
---|---|
hash | Returns the anchor portion of a URL |
host | Returns the host name and port of a URL |
hostname | Return the host name of the URL |
href | Return the complete URL |
pathname | The returned URL path name. |
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 method
Method | Description |
---|---|
assign() | Load a new document |
reload() | Reload the current document |
replace() | Replace the current document with a new one |