Sometimes you need to redirect to a page from client side JavaScript. You can do this in two ways:
- Go to a specific page with a “link pressed” like behavior. That means that your current page will be put into the browser’s back stack:
window.location.href = "www.redirect-url.com";
- Do not add the current page to the back stack. This is very similar with a server side redirect:
window.location.replace("www.redirect-url.com");