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 window. The Location property accesses it.
Note: There is no public standard applied to the Location object, but it is supported by all browsers.
Location object properties
Property | Describe |
---|---|
hash | Returns the anchor portion of a URL |
host | Returns the host name and port of a URL |
hostname | Returns the host name of the URL |
Href | Return the full URL |
pathname | The name of the URL path returned. |
port | Returns the port number used by a URL server |
protocol | Returns a URL protocol |
search | Returns the query section 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 document |