Results 1 to 2 of 2

Thread: iframe onclick top of page code????

  1. #1
    Join Date
    Oct 2007

    iframe onclick top of page code????


    I am building a website currently that has:

    A main page which has an iframe in it (the parent page). There is a menu on this page where the links are targeted to open in the iframe. The iframe has scrolling disabled and the iframe adjusts to fit the content of the child page.

    My question is... is there a way to make the page scroll to the top (of the parent page) when a link is clicked instead of the parent page remaining scrolled half way down where the link originally was clicked on the previous child page.

    I was thinking maybe something along the lines of "onClick". I have tried a few codes I've found online but none seem to work. I don't want this code to interfere with the code I currently have that resizes the iframe to fit the child page contents.

    I'm pretty new to all this so please be patient.


    iframe1 = one of the pages of my site. a list of linked images in the iframe. yellow text just letting u know where everything is.
    iframe2 = this is what happens when the link is clicked. notice the page is scrolled down a bit.
    iframe3 = this is how i want the page to load when a link is clicked. scrolled up to the top.
    Attached Images Attached Images

  2. #2
    Join Date
    Apr 2003
    Add this to all the iframe documents:
    window.onload=function() {top.scrollTo(0,0);};
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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