Javascript redirect user to another page

Javascript redirect user to another page

Today, We are going to learn How can We redirect a user from one page to another page using JAVASCRIPT. Sometimes, We need to redirect from one page to another using JAVASCRIPT. Once, the Ajax request is complete in many cases we need to redirect a user to another page using JAVASCRIPT. So, Let’s see Javascript redirect user to another page.

Javascript redirect user to another page

window.location.replace("http://thecodingstuff.com");

window.location.href = "http://thecodingstuff.com";

Using “window.location” we can redirect a user from one page to another page. You can get more information about window.location from here.

I prefer to use “window.location.href” instead of “window.location.replace” Because the replace method doesn’t keep the originating page in the history. The user gets stuck in Back history fiasco.