How to redirect to another url in javascript?

you can set the location of the window.

window.location = "";

The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.

window.location.href = "";

It is containing the entire URL. If changed, the associated document navigates to the new page. It can be set from a different origin than the associated document.


Replaces the current resource with the one at the provided URL

Add a Comment

Your email address will not be published. Required fields are marked *