---
title: "Redirect to another webpage through JavaScript"  
description: "Redirect to another webpage through JavaScript"  
author: "Anonymous User"  
published: 2021-07-19  
updated: 2023-11-29  
canonical: https://www.mindstick.com/forum/156527/redirect-to-another-webpage-through-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Redirect to another webpage through JavaScript

How do I [redirect](https://www.mindstick.com/forum/2005/radio-button-redirect) to another webpage through [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript)? And how [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) [redirection](https://www.mindstick.com/forum/436/url-redirection) works?

## Replies

### Reply by Aryan Kumar

You can redirect to another webpage in JavaScript by setting the **window.location** property to the URL of the destination. Here's an example:

```plaintext
// Redirect to another webpage
window.location.href = "https://www.example.com";
```

This line of code changes the current location of the browser to the specified URL, effectively redirecting the user to the new page.

You can also use **window.location.replace()** for a similar effect:

```plaintext
// Redirect using replace
window.location.replace("https://www.example.com");
```

The difference between **window.location.href** and **window.location.replace()** is that the latter replaces the current page in the browser's history, making it so that the user cannot navigate back to the previous page using the browser's back button.


---

Original Source: https://www.mindstick.com/forum/156527/redirect-to-another-webpage-through-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
