How to redirect a page to another page in Javascript?

devquora
devquora

Posted On: Feb 23, 2023

 

There are several ways to redirect page to another page in JavaScript. These are:

  1. Using location.href: It is the first approach to redirect page. In this, we can go back to access the original document. Syntax:window.location.href =“https://www.onlineinterviewquestions.com/”
  2. Using location.replace: Another approach to redirect page. In this, it is not possible to navigate back to the original document by clicking on the back button as it removes the URL of the original document. Syntax: window.location.replace(" https://www.onlineinterviewquestions.com/");

    Related Questions

    Please Login or Register to leave a response.

    Related Questions