views:

768

answers:

2

At this point we have a photogallery which uses hashvalues to determine which picture is currently showed to the user, and to support sending the page to a friend and such. Something like:

http://url/photos/#photo-4

When we have loaded the corresponding picture after clicking the next or previous button, we change the url according to the JS 1.1 specification using:

top.location.replace(url.url + hash);

Our wanted behaviour is that no history item is being created, so users can use the back button to leave the photogallery, instead of using the back button to see the previous pictures.

In IE and Firefox the method works like a charm, but Safari and Chrome do make a history item for the changed url. I have found alot of samples how to create history items when using the hash for navigating like this, but I want to do this the other way. Any clue?

A: 

Have you looked at assigning your hash using window.location.hash = newHash instead of replacing the entire url?

https://developer.mozilla.org/en/DOM/window.location

CptSkippy
Yes"replace(url) Replace the current document with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it."And there I got my bug, because that doesn't work in Webkit.
Jan Jongboom
I'll clarify my answer
CptSkippy
location.hash creates history items in all the major browser apart from IE, so that won't work :-)
Jan Jongboom
+1  A: 

There seems to be no solution at this point.

Jan Jongboom