Anchor link in iframe makes parent page scroll too

Discussion in 'HTML & Website Design' started by knkk, Aug 8, 2007.

  1. #1
    I have an iframe in a page (with a name to the iframe), and in that iframe I have several anchors

    <a name="something">
    Code (markup):
    There are links in the iframe that look like

    <a href="#something">
    Code (markup):
    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">
    Code (markup):
    Does anyone know a solution? Thank you very much for your time.
     
    knkk, Aug 8, 2007 IP
  2. knkk

    knkk Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    knkk, Aug 12, 2007 IP