View Full Version : Javascript link from page in iframe to parent, with anchor

01-14-2007, 06:48 PM

I have a problem with getting this to work:

A larger page largetest.php has an iframe. The page in the iframe is smalltest.php.
Smalltest.php has two small thumnail images as links.
These are red.jpg and blue.jpg.
Clicking on the red image refreshes the parent page largetest.php and this link uses a link to an ID #footer, like a named anchor.
Same happens with the blue image link.

Link code on the smalltest page in the iframe:

<a href='javascript: parent.location.href="largetest.php#footer"'>
<img src="graphics/red.jpg" width="95" height="62" border="0"/></a>
<a href='javascript: parent.location.href="largetest.php?name=George"+"#footer"'>
<img src="graphics/blue.jpg" width="95" height="62" border="0"/></a>

When the larger page refreshes, it reloads the smalltest page in the iframe.
All works fine, even if the links have query strings like the 'blue' link, if the blue link is clicked, then red, then blue etc,
but fails if red link clicked, and then after pages refresh is clicked again.
Then the iframe page smalltest fails to display and it just shows the link text in the iframe, with no page present.

It fails when either image link is clicked more than once in succession.
red blue red blue: fine
red red: fails.

Without the '#footer' in the links, there is no problem, but I need the largetest page to display the bottom half of the page.

Could be a cache problem?

Can anyone help with this?

01-15-2007, 06:02 PM
This is now resolved. Just using onclick instead of pseudo-link

Bill Posters
01-15-2007, 08:49 PM

<a href="largetest.php#footer" target="_parent"><img src="graphics/red.jpg" width="95" height="62" border="0" /></a>
<a href="largetest.php?name=George#footer" target="_parent"><img src="graphics/blue.jpg" width="95" height="62" border="0" /></a>