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 to the CF scene
    Join Date
    May 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    scroll to top with iFrame and anchor link

    Been beating my head against the wall on the one for a while now. I have a page with an iFrame. The src of the iFrame is a page with an anchor link. When the iFrame src URL jumps to the #anchor, the outer window scrolls down as well. Ugh. Here's what I'm talking about:

    http://www.singley.org/test/test.html

    I tried adding a self.scrollTo(0, 0) line of javascript at the bottom of the parent page, and on the onload of the iFrame, but neither worked. If I add that code to a link or button, however, I can scrollTo the top of the page onClick no problem.

    So, anyone know how I can scroll the outer window back to the top when the page loads? Thanks!

  • #2
    Regular Coder
    Join Date
    May 2006
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi ChitownE,

    Add a setTimeout like below:
    Code:
    <br>
    <br>
    Page Bottom
    <script>
    setTimeout("self.scrollTo(0,0)",1);
    </script>
    </body>

  • #3
    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.


  •  

    Posting Permissions

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