Categories
JavaScript Answers

How to replace a window’s URL hash with another response with JavaScript?

Spread the love

Sometimes, we want to replace a window’s URL hash with another response with JavaScript.

In this article, we’ll look at how to replace a window’s URL hash with another response with JavaScript.

How to replace a window’s URL hash with another response with JavaScript?

To replace a window’s URL hash with another response with JavaScript, we can set the window.location.hash property.

For instance, we write

window.location.hash = "#food";

to replace the hash of the current URL with #food.

Conclusion

To replace a window’s URL hash with another response with JavaScript, we can set the window.location.hash property.

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 *