Firefox, Iframes and history.go....

Hi,

I am struggling for a while now with the following issue:

I am currently working on a photography site. I created a page containing a table for the thumbnails and an Iframe showing the full version of the image when clicking on one of the thumbnails.

I also included two navigation buttons (images rather), 'Previous Page' and 'Next Page' to navigate from one page to the other.

The problem lies in the 'Previous Page' button. I thought I found a simple solution in the history.go(-whatever) statement and this is true for IE. However, Firefox seems to give me some problems.

The code I am using for navigating via the 'Previous Page' button is as follows:

function goBack(){
var blah;

blah = 0 - document.getElementById('counter').value - 1;

history.go(blah);
}

The element counter contains a certain value. So basically the thought is to take this value and deduct it from 0. After this I deduct another -1 to make sure I end up on the page I want.

I have chosen for this approach because whenever a thumbnail is clicked a new page is opened in the IFrame. If I would simply use history.go(-1); the page inside the IFrame will go back one page, rather than the required parent page.

The current situation is that in IE the user is taken to the required page (so the parent page is changed). In Firefox however the parent page is not switching. It seems Firefox is simply reloading the current page.

I hope it still makes sense.

Hopefully someone can help me with this.

Thanks in advance.

With kind regards,

Oculas
[1735 byte] By [oculas] at [2007-11-20 0:02:37]
# 1 Re: Firefox, Iframes and history.go....
Okay, Firefox also uses history.go() the same as IE. I am not sure why that scheme does not work, but here is what you can do...

In Firefox, click on the menu tools and select JavaScript Console. Clear all errors and then attempt your code. If there is an error, it will show up there and you can debug it. Let us know.
PeejAvery at 2007-11-8 0:40:44 >
# 2 Re: Firefox, Iframes and history.go....
I forgot to mention that... that's the weird thing, it does not return an error as it does refresh the current page.

Thank again.

Oculas
oculas at 2007-11-8 0:41:44 >
# 3 Re: Firefox, Iframes and history.go....
The JavaScript Console is a log of JavaScript errors, not just a display of the current page's errors.

No matter what, if the error occured, it will be in the JavaScript Console until cleared.

So, that means that JavaScript does not even recognize it as an error. Tell it to alert(blah) and see what Firefox thinks it is.
PeejAvery at 2007-11-8 0:42:40 >
# 4 Re: Firefox, Iframes and history.go....
Thanks for your input Peejavery.

I found out what was causing my issue. Turns out that not the javascript was at fault, but the way I used it. I put the code on a link with href="#"... it didn't really like that.

However,I seem to be running in another problem now, also related to the history.go() statement.

What I did, for testing sake, is to remove the href from the image I am using. I put the javascript goBack(); directly on the image. But now it seems the previous Page button does not really want to cooperate after I have been viewing some images.

you can try for yourself at: http://www.junglefrog.nl/index_test.php

Just go to the second page, click some thumbnails and try to go back to the first page via the left-pointing arrow (the Previous Page button).

You will get an alert showing how many pages should be backflipped.

The code I am using is:

function goBack(){
var blah;
blah = document.getElementById('countertje').value - 1;

alert("I should go back " + blah + " pages.");

history.go(document.getElementById('countertje').value - 1);
}

Hopefully someone can help me finding a solution for this one as well.

Thanks again.

With kind regards,

Oculas
oculas at 2007-11-8 0:43:48 >
# 5 Re: Firefox, Iframes and history.go....
Glad you solved it!
PeejAvery at 2007-11-8 0:44:45 >