How to redirect to another page in JavaScript function?

To redirect the user from one page to another using JavaScript.

You can redirect to another webpage using JavaScript using location.replace() method

window.location.replace("https://datapearls.org/blogs/use-strict-in-javascript");

 

Another example is the following  using  href property 

window.location.href = "https://datapearls.org/blogs/use-strict-in-javascript";

Tags:

Share:

Related posts