View Full Version : Is there a limit to History.go()?

11-03-2006, 02:52 PM
Hi all :)

I have a small website for displaying my pictures to the world ( www.pictures-of-paradise.com ), and have just added 'prev' and 'next' buttons to the 'display' page. You get to the display page from the 'categories_grab' page where all the images in the category that has been chosen are displayed as thumbnails.

I wanted to be able to return to the 'categories_grab' page at the same position it was when a thumb is clicked, so I made a variable '$num_clicks' and pass this in the command line, incrementing it by -1 everytime one of the buttons is clicked, and then in the 'anchor' attached to the picture I put <a href='javascript: history.go($num_clicks)' target='_self'>.

Everything is working fine, until it reaches -50 when it stops working... :mad:

Is there a limit to the number of histories 'history.go()' will access? Or is it something else I am doing wrong? Any ideas or suggestions please :)

Thanks in advance for any help anyone can give.

11-03-2006, 03:14 PM
History.go may not be better idea.

My Pseudo normally flows as

currentImageNum = 0;
totalImageNum = 50

### For Next Button ###

if currentImageNum < (totalImageNum-1)
currentImageNum = 0;

call showImage(currentImageNum );
###For Prev Button ###

if (currentImageNum > 0 && currentImageNum <> (totalImageNum-1))

call showImage(currentImageNum );

11-03-2006, 03:44 PM
Iota, thanks for your reply.

I'm not sure you understand the problem...

First I should note that I am using 'PHP' for my coding, I forgot to mention that before. I'm fairly new to all this by the way.

The problem is not with the navigation buttons, I have them working fine, but if after, either viewing all images in a category with more than 49 images, or just going backwards and forwards through the images more then 49 times, the history.go(-50) fails to function! anything less then (greater than since its a negitive number...) 50 and it works fine, returning you to the 'Categories_grab' page, and scrolled down to the place you left it. So History.go(-49) works, and History.go(-50) fails.

Perhaps I have not understood your code (that is very likely)...


11-04-2006, 06:42 AM
Well, not that im not grateful, but the answer I recieved was in 'code'ish', that made virtually no sense to me (being a part time human), and didn't even answer my question, as far as I can tell.

For anyone that is interested, the limit to History.go() that I am experiencing is infact in the number of history states saved by the browser... Simple eh.

Now the problem is returning to the Categories_grab page, scrolled down to the same place, but I dont really hold out any hope of getting a reply that I can understand here, but I will check it out for awhile.


11-04-2006, 08:09 AM
Yeah common sense tells me that the history.go() just goes back like a web browser, which stores the previous pages on the local computer. To save space, they have to limit the amount of pages they save. That's just my guess so don't quote me.

And I don't think it's possible to return to the page at the same spot unless you use "anchors" (e.g. <a href="http://blah.com/pics.html#picture_1">Pic</a> ... <img src="http://blah.com/pics/picture_1.jpg" name="picture_1" />) That should link to the picture. With php, you could have it make the anchor the picture id, if you're linking to pics from a database, and then the Back to the Categories link could be something like <a href="http://blah.com/pics.php#<insert ID with PHP here">Link</a>. I hope that helps.

11-04-2006, 08:25 AM
I'm not sure yet will have to research your suggestions, but they sound hopeful actually, using the pictures id (which I would have to give them ;) ) is promising, since I was unsure about going to an anchor on a page made by php. Will have a look.

Thanks very much Yaggles, you must be part human aswell :thumbsup:


11-07-2006, 06:58 PM
Me again :)

I gave the thumbs a 'name' each and passed it to the 'display page' in the command line.

When using an anchor with php and passing arguements im not sure of the syntax... I tried "<a href='categories_grab.php#$image_id?cat=$cat&num_images=$num_images'>" but it loaded the page with '0 images'. I removed the anchor, e.g. "<a href='categories_grab.php?cat=$cat&num_images=$num_images'>" and the page loaded fine.

Is there a problem with my syntax, or is there a problem with going to an anchor on a php page that possibly has not yet been created?