Property | Description |
location.href | Full URL string. |
location.protocol | Protocol Used in URL |
location.host | Hostname string |
location.hostname | Domain part of the URL |
location.port | Port Number of the URL |
location.pathname | String starting from / giving path from the URL |
location.search | QueryString starting from ? from the URL |
location.hash | String followed by # in URL |
location.href to extract path from URL
location.hostname to extract hostname from URL
location.reload to Refreshing the current page
Methods | Description |
location.assign() | Opens the provided URL in browser. You can use Back Button to return to this page.
|
location.reload() | Reloads Current URL.
|
location.replace() | Replace with provided URL and opens the page. While moving to provided ( URL) page , the current page will not be saved in session history, so you can't use Back button of browser to return to the parent ( this ) page. So a link is provided in Demo page to return to this page. This is the main difference between location.assign() and location.replace()
|
location.toString() | Returns the full URL as string . On Click location.toString() Method will return one alert Box with the URL String
|