View Full Version : Anchor link in iframe makes parent page scroll too

08-08-2007, 06:08 PM
I have an iframe in a page (with a name to the iframe), and in that iframe I have several anchors

<a name="something">

There are links in the iframe that look like

<a href="#something">

The problem is, when any of these links is clicked, along with the iframe, the parent page scrolls up too to the beginning of the iframe.

I tried this, doesn't work:

<a href="#something" target="the_iframe_name">

Does anyone know a solution? Thank you very much for your time.

Mr J
08-08-2007, 10:58 PM
See if these examples help you



08-12-2007, 08:16 AM
Thanks Mr J. Well, my problem was that the link to go to the anchor is also in the iframe (in your examples the link is outside).

I could not solve this problem using anchors, so I found a different way - I kept track of the x,y co-ordinates of the scroll position of the page (where the anchor would have been) and used the javascript scrollTo(x,y) instead to go to that part when the "a href" was clicked on.