Sometimes, we want to reload the page with hash value with JavaScript.
In this article, we’ll look at how to reload the page with hash value with JavaScript.
How to reload the page with hash value with JavaScript?
To reload the page with hash value with JavaScript, we can set the window.location.hash
property to the hash string.
Then we reload the page.
For instance, we write
window.location.hash = "#mypara";
location.reload();
to set window.location.hash
to the hash string to append it to the end of the URL.
Then we call location.reload
to reload the page.
Conclusion
To reload the page with hash value with JavaScript, we can set the window.location.hash
property to the hash string.