Zerium
Zerium

Reputation: 17333

How to reload browser page by just appending a hash?

For example, when I am on http://www.example.com/foo and I use this:

window.location.href = "http://www.example.com/foo#bar";

The default action is that the page doesn't reload, and it just moves me over to the element with id="bar".

But what if I explicitly want the page to refresh? How would I do that?

I can use jQuery if necessary.

Thanks.

Upvotes: 1

Views: 47

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82251

You can reload the page just after changing the location. Like this:

window.location.href = "http://www.example.com/foo#bar";
location.reload();

Upvotes: 2

Related Questions