View Full Version : browser history loses urls

01-23-2006, 12:04 PM
I've written my site so that bigger versions of images can be launched in a new 'viewer' window.
This window stays open and accumulates the pictures which are chosen from the main page.
I've written a simple javascript 'back' and 'forward' so that users can view the images collected in the viewer window.

The problem:
If you use the 'back' to go to previous pics, the history disappears.
ie: you choose pics 1, 2, 3. You go backwards in the viewer window - 2, 1. You go into the main window and chose a other pic, 4. You want to see pics 2 & 3 again, so you click the back button, but the history for 2 & 3 has gone.

Is this a history problem, or a browser problem, or a coding problem?

Many thanks

01-23-2006, 01:43 PM
Is this a history problem, or a browser problem, or a coding problem?

well, my crystal ball is on the blink today, so you'll have to post some code for me to help you. I presume others might think the same, too, not being privy to their psychic abilities either. :rolleyes:

01-23-2006, 02:50 PM
My crystal ball is getting these weird signals... They look somewhat like this:

1. image 1
> (User goes to next image)
2. image 2
> (User goes to next image)
3. image 3
> (User reverts to history location 1)
1. image 1
> (User goes to image 4)
2. image 4 (this replaces the earlier forward history)

If that explains what happens, you should also see why it behaves like it does. You're using the history for something it wasn't meant to do.

01-23-2006, 07:14 PM
Yes, that's what happens. I had always had the impression (obviously hadn't looked carefully enough) that history recorded urls visited, in the order they were visited, and wiped addresses if they had moved further up the list -
1 > 2 > 3 > 2 > 1 > 4 would result in a history of 4, 1, 2, 3.

So, is there any simple way of not losing addresses? Looks like it had better be simple...

01-23-2006, 07:45 PM
The only way to not lose those visits would be to keep count of how many back button presses had occurred and go forward that far in history before loading the next page (and zeroing the back count).

01-23-2006, 08:45 PM
Tamcole: Navigation and history are separate - if a user navigates somewhere, it's added as the next item in history, replacing any previous forward history from that point. Moving from one point in the history to another on the other hand doesn't change anything in the history itself. As felgall said, the only way to get around this would be to store the number of history jumps you've been doing. And that would break any user using the browser history UI instead of your JavaScript UI.

Trying to illustrate this:

1 2 3 4
2:image1 IMAGE2
3:image1 image2 IMAGE3
1:IMAGE1 image2 image3
2:image1 IMAGE4