Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    61
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Anchor link in iframe makes parent page scroll too

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

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

    Code:
    <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:

    Code:
    <a href="#something" target="the_iframe_name">
    Does anyone know a solution? Thank you very much for your time.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    61
    Thanks
    13
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •