# How to redirect to another web page with JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Sep 18, 2021. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-redirect-page

> A quick guide to learn how to redirect to another web page with JavaScript.

In JavaScript, The `assign()` method of the `Location` object can be used to navigate to a new web page.

Here is an example:

```javascript
location.assign(`https://attacomsian.com/protips`);
```

The `replace()` method is another way to load a new web page in JavaScript. It works similar to `assign()` except that it simulates an HTTP redirect and doesn't create an entry in the browser's history. It means that the user won't be able to use the back button to navigate back to the original document:

```javascript
location.replace(`https://attacomsian.com/protips`);
```

Finally, the last way to redirect the user to another web page is by using the `location.href` property. It resembles the user's click event and produces the same effect as using the `assign()` method:

```javascript
location.href = `https://attacomsian.com`;
```

Take a look at [JavaScript location object](https://attacomsian.com/blog/javascript-location-object) tutorial to learn more about the `Location` object properties and methods.
