Window interface has access to the
Location object that can be used via
Included in the
Location interface is a
href value, which represents a USVString containing the whole URL for a page.
This value can also be assigned a different and new URL:
window.location.href = "https://www.google.com"
By setting a new value for
location.href, the page will navigate to the new URL you provide.
By navigating to a new page in this manner, the original page will stay in the session
History. Therefore, users will be able to use the back button in their browser to return to the original page.
For more information on the browser support for the
location.href method, see its MDN web docs page.
Thanks for reading and happy coding!