How can I redirect the user from one page to another using JavaScript?

 We can redirect a web page to another page using JavaScript. So in that case you have 3 options using JavaScript:



1) Using location replace, will replace the current history of the page, which means that it is not possible to use the back button to go back to the original page.

window.location.replace("https://www.neerajcodesolutions.com/");

 

2) Using location assign, this will keep the history for you and by using back button, you can go back to the original page:

 

window.location.assign("https://www.neerajcodesolutions.com/");

 

3) I recommend using one of those previous ways, but this could be the third option using pure JavaScript:

 

window.location.href="https://www.neerajcodesolutions.com/";

How can I redirect the user from one page to another using JavaScript? How can I redirect the user from one page to another using JavaScript? Reviewed by NEERAJ SRIVASTAVA on 12:29:00 PM Rating: 5

No comments:

Powered by Blogger.