window.location for read and write access to the location object associated with the current frame. If we just want to get the address as a read-only string, we may use
document.URL, which should contain the same value as
Gets the current page URL:
To get the path, we can use:
- Use window.location.href to get the complete URL.
- Use window.location.pathname to get URL leaving the host.