You can redirect the user to a different page with pure JS by changing the global property window.location.

Here’s how it’s done:


This code sample redirects the user to the website and it’s an equivalent of the HTTP redirect.

If you’re looking for the behaviour that’s similar to clicking a link, you should update the property window.location.href

window.location.href = "";

Whatever you choose the user will end up redirected to a new web page.