www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: IFRAME: scrolling to the top

  1. #1
    Join Date
    Jul 2004
    Location
    17 saffier road, mayberry park Alberton South, Johannesburg, South Africa
    Posts
    5

    IFRAME: scrolling to the top

    Hi, I have currently designing a site using iframe to load content. Whenever a new page is loaded while the scroll if e.i in the middle of the page, this new page is not taken to the top. What can I do. page can be viwed at abexnet.org. Please help
    MB Henrikennyo

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    put this in iframed page(s)

    <body onload="location.href='#top'">

    or even

    <body onload="location.href='#'">

  3. #3
    Join Date
    Nov 2002
    Location
    Dartmoor [Holiday]
    Posts
    2,382
    Please don't cross-post.

    Adam
    "If youíre not using valid HTML, then you havenít created a Web page. You may have created something else, but it isnít a Web page." - Joe Clark

    Do something amazing (USA) | Make Poverty History

  4. #4
    Join Date
    Jul 2004
    Location
    17 saffier road, mayberry park Alberton South, Johannesburg, South Africa
    Posts
    5

    Thumbs up IFRAME

    Originally posted by Kor
    put this in iframed page(s)

    <body onload="location.href='#top'">

    or even

    <body onload="location.href='#'">
    Thanks a million for your help. It did it and it worked perfecly. ciao
    MB Henrikennyo

  5. #5
    Join Date
    Oct 2009
    Posts
    9

    Thumbs up

    Thanks a billion!! I was looking for a solution like this for AGES!

  6. #6
    Join Date
    Oct 2009
    Posts
    9

    Question

    Guys, it doesn't work on Firefox. Is there a solution for firefox? Can't find it anywhere.

  7. #7
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by kikinney View Post
    Guys, it doesn't work on Firefox. Is there a solution for firefox? Can't find it anywhere.
    Should work in all the browsers. Probably you have another javascript code which uses window.onload as well in your iframe. can we see a test page, or the significant part of your code?

  8. #8
    Join Date
    Oct 2009
    Posts
    9
    Here's the index.htm

    Code:
    <HTML>
    <HEAD>
    <title></title>
    </HEAD>
    
    
    
    
    <BODY background="bg_top.jpg" onload="location.href='#'" bgcolor="#B3B79E" text="#000000" link="#000000">
    
    <br><br><br>
    
    <p align="center"><iframe name="geral" onload="location.href='#'" src="geral.html" frameborder="0" width="940" height="1700"></p>
    
    
    
    
    </BODY>
    </HTML>
    And here's there main iframe (geral.html)

    Code:
    <HTML>
    <HEAD>
    
    
    
    <link rel="stylesheet" href="stylex.css" type="text/css" charset="utf-8" />
    
    
    <title> </title>
    </HEAD>
    
    <BODY background="bg_geral.jpg" onload="location.href='#'" bgcolor="#000000" text="#000000" link="#000000" scroll="no">
    
    
    <iframe name="top" src="top.htm" frameborder="0" height="190" width="938" frameborder="0" style="position: absolute; top: 0px; left: 0px;"></iframe>
    
    <iframe name="middle" src="middle.htm" onload="location.href='#'" frameborder="0" height="1808" width="902" frameborder="0" style="position: absolute; top: 190px; left: 18px;"></iframe>
    
    
    
    </BODY>
    
    </HTML>
    onload="location.href='#'" has no effect on Firefox and the error complains about Location.toString on Line 0

  9. #9
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Code:
    <iframe name="geral" onload="location.href='#'" ...
    You have placed the onload event into the IFRAME element, not into the BODY element of the document loaded in that iframe. It is not the same thing..

    Anyway, do otherwise: Inside the HEAD of the document you want to scroll to the top onload put this code:
    Code:
    <script type="text/javascript">
    onload=function(){location.href="#";}
    </script>

  10. #10
    Join Date
    Oct 2009
    Posts
    9
    the onload="location.href='#'" was placed in the iframe element and the body of geral.html , just in case I did put on both places. I tried your last code Kor, but firefox still don't go to the top. God, I hate firefox so much, everytime I find something that works on IE, bugs on FF.

  11. #11
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by kikinney View Post
    the onload="location.href='#'" was placed in the iframe element and the body of geral.html , just in case I did put on both places. I tried your last code Kor, but firefox still don't go to the top. God, I hate firefox so much, everytime I find something that works on IE, bugs on FF.
    Sir, don't blame FF, blame yourself as you did not coded well. Once again, the code I have provided should work 100% in all the browsers. Except that you must not insert the onload into the IFRAME element, as I told you before.

  12. #12
    Join Date
    Oct 2009
    Posts
    9
    Kor, I'm sorry, I'm a girl. I tested your code without the onload (in every page) but still doesn't work. I belive you, that I'm the one doing something wrong, I just don't know what is it. I'll upload the page so you can see it.

  13. #13
    Join Date
    Apr 2006
    Location
    Houston
    Posts
    1,374
    The onload goes in the body tag of middle.htm and geral.html, not index.htm or the iframe tags.

  14. #14
    Join Date
    Oct 2009
    Posts
    9
    Quote Originally Posted by slaughters View Post
    The onload goes in the body tag of middle.htm and geral.html, not index.htm or the iframe tags.
    Yes, works perfectly on IE but not on FF. I'm uploading the page, this way the changes I make can be seen

  15. #15
    Join Date
    Oct 2009
    Posts
    9
    So here's the page

    http://kikinney.googlepages.com/index.html

    inside the index.html there's an iframe, geral.html

    the main iframe (geral.html) has 2 iframes:

    >> the top.htm iframe (the menu)
    >> and the middle.htm (the content) , INSIDE the middle.htm is where everything happens, for example:

    If you scroll the index to '' nossos PACOTES '' part, where you have 4 pictures of places, and click in any of them, the page will load in the same place you were before. I tried one thousand codes to force the page to go to the top, and everything works on IE, but not on FF.

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



Recent Articles