You can use the assign() method of the Location object to navigate to a new web page in JavaScript.

Here is an example:


The replace() method is another way to load a new web page in JavaScript. It is almost identical to assign() except that it simulates an HTTP redirect and doesn’t create an entry in the browser’s history. It means that the user won’t be able to use the back button to navigate back to the original document:


Finally, the last way to redirect the user to another web page is by using the location.href property. It resembles the user’s click event and produces the same effect as using the assign() method:

location.href = ``

Take a look at JavaScript location object tutorial to learn more about the Location object properties and methods.