tags:

views:

40

answers:

3

The title might be a bit misleading, but I don't know how else to explain it.

Basically I'm at this URL:

www.mysite.com/shop/6-dresses#filter=[manufacturer:4]

And I want to make a link that would change it to

www.mysite.com/shop/6-dresses#filter=[manufacturer:5]

(e.g. like <a href="www.mysite.com/shop/6-dresses#filter=[manufacturer:5]"></a>)

But it doesn't seem to load unless I click on it and refresh the page after.

Is there anyway I can alter the link code so that it forces to reload the page fully?

A: 

have you tried window.location = "www.mysite.com/shop/6-dresses#filter=[manufacturer:5]"

KoolKabin
He probably has, but it probably won't reload the page, as it's just the anchor fragment that changed.
Pekka
+2  A: 

You'll have all you need here : https://developer.mozilla.org/en/window.location#Methods

Fabien Ménager
yup, reload() should work.
Pekka
Thanks, that worked!
Ken
I've seemed to hit a snag with this method. If I try to click on the link from a different page i.e /shop/ it will just refresh and not change the page. It works if there is already a fragment in the URL.
Ken
A: 

The only difference between both links is the fragment identifier. That's why the page isn't reloading. The reason for this is RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax (emphasis mine):

When a URI reference refers to a URI that is, aside from its fragment component (if any), identical to the base URI (Section 5.1), that reference is called a "same-document" reference.

[...]

When a same-document reference is dereferenced for a retrieval action, the target of that reference is defined to be within the same entity (representation, document, or message) as the reference; therefore, a dereference should not result in a new retrieval action.

You're fighting against the browser's correct behavior, and implicitly going against the user's expectations. I suggest you change the URLs to something like this:

www.mysite.com/shop/6-dresses?filter=[manufacturer:5]#filter=[manufacturer:5]

This will result in a reload of the page, without being dependent on JavaScript. Stack Overflow uses a similar approach for linking to answers:

stackoverflow.com/questions/3483627/some-question/3483650#3483650
Niels van der Rest