Javascript reload the page with hash value
javascript, jquery
Solution
window.location.href += "#mypara";
location.reload();
First add the hash, then reload the page. The hash will remain there, and the page gets reloaded.
Tested, works.
ps: If a hash already exist in the URL, you may want to directly change it via `location.hash` instead of `.href`.
Problem
I am trying to refresh the page with this statement in external javascript file after some processes. ``` window.location.href = window.location.href ``` It perfectly reload the page but I want to scroll to the specific location after reload. So, I put this on the page. ``` <a name="uploadImgSection"></a> ``` And change the javascript to ``` window.location.href = window.location.href + "#mypara"; ``` This code doesn't reload/refresh the page either ``` window.location.hash = "#uploadImgSection"; window.location.href = window.location.href; ``` When I do that, it doesn't reload the page at all. Is there any way I can reload the page with scroll bar position?