lisovaccaro
lisovaccaro

Reputation: 33946

change Window.location with javascript even while using hash?

I want to refresh with new hash but it seems chrome just changes the hash instead of redirecting as it's the same URL.

How can I do it?

window.location = "http://lujanventas.com/" + shopURL + "#" + name;

Upvotes: 1

Views: 890

Answers (1)

jfriend00
jfriend00

Reputation: 707148

The simplest thing would be to slightly change the URL with a URL parameter to force the browser to reget the page:

window.location = "http://lujanventas.com/" + shopURL + "?random=" + (new Date()) + "#" + name;

By definition a hash change only is only supposed to just go to that hash - it isn't supposed to reload the page so the way you have it now, it's doing what it's generally supposed to. Without explicitly doing a page reload first, you have to trick it into loading the URL over again when you change the hash. Adding a different parameter to the URL will trick it.

Upvotes: 1

Related Questions