Using the replace() and assign() JavaScript functions we can redirect to another URLs.

With the replace() function, we create a redirect where the previous page will be replaced, thus inaccessible through the browser’s back button:

window.location.replace("https://pineco.de");

With the assign() funlction, we can trigger a mouse click like navigation so it will redirect us to the new page, but we can still navigate back:

window.location.assign("https://pineco.de");

There is a third method which is the window’s read-only location object, where we can pass any string (valid URL):

window.location = "https://pineco.de";