Categories
TypeScript Answers

How to set window.location with TypeScript?

Spread the love

Sometimes, we want to set window.location with TypeScript.

in this article, we’ll look at how to set window.location with TypeScript.

How to set window.location with TypeScript?

To set window.location with TypeScript, we can set the window.location.href property to the URL path we want to go to.

For instance, we write

window.location.href = "/url";

to navigate to the /url URL by setting window.location.href to the URL string.

Conclusion

To set window.location with TypeScript, we can set the window.location.href property to the URL path we want to go to.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *