Connecting Tech Pros Worldwide Forums | Help | Site Map

Anchor link in iframe makes parent page scroll too

Member
 
Join Date: Jun 2007
Posts: 36
#1: Aug 8 '07
I have an iframe in a page (with a name to the iframe), and in that iframe I have several anchors

Expand|Select|Wrap|Line Numbers
  1. <a name="something">
There are links in the iframe that look like

Expand|Select|Wrap|Line Numbers
  1. <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:

Expand|Select|Wrap|Line Numbers
  1. <a href="#something" target="the_iframe_name">
Does anyone know a solution? Thank you very much for your time.

epots9's Avatar
Moderator
 
Join Date: May 2007
Location: Canada
Posts: 1,313
#2: Aug 8 '07

re: Anchor link in iframe makes parent page scroll too


are u closing your tags?
[html]
<a href="#something">go to something</a>
<a name="something">about something</a>
[/html]
Member
 
Join Date: Jun 2007
Posts: 36
#3: Aug 12 '07

re: Anchor link in iframe makes parent page scroll too


Sorry for the delayed response. Yes, I was closing the tags.

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.
Reply