JavaScript Page direct
Last updated
Last updated
The window.location object in JavaScript can be used to send the viewer to a separate web website.
Example:
window. location.href = "
";
In this example, you will set the href property of the window. location object to a new URL (), which causes the browser to navigate to that URL.
You can also use the location.replace() method to redirect the user to a new page, but with the additional feature of replacing the current page in the browser history, which means that the user can't navigate back to the previous page using the Back button. Here's an example:
window. location.replace("");
In this example, you will call the replace() method of the window. location object with the new URL () as the argument, which causes the browser to replace the current page with the new page, effectively removing the current page from the browser history.