Results 1 to 4 of 4

Thread: problem with scrollto()

  1. #1
    Join Date
    Apr 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem with scrollto()

    hi everyone

    i have this code in some page i made

    <html>
    <body onload="window.scrollTo(500,500)">
    <iframe src="http://somewebpage.com" width="250" height="150"></iframe>
    </body>
    </html>

    and it's not go to the coordinate on the onload event :\ anyone know how i can fix that?

    what i want to do is webpage that open another webpage in specific coordinates.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The code for the page in your post says to scroll the window to 500x500. But, the only thing on the page is an iframe of the dimensions 250x150. If the window did scroll to 500x500, there would be nothing there. You seem to want to scroll the iframe. If it is on another domain, that gets tricky. If it is on your domain, just put the body onload event on the page in the iframe.

    I think it is on another domain. If so, you need another page.

    Top page:

    HTML Code:
    <html>
    <body>
    <iframe src="somepage.htm" width="250" height="150"></iframe>
    </body>
    </html>
    somepage.htm:

    HTML Code:
    <html>
    <body onload="window.scrollTo(500,500)">
    <iframe src="http://somewebpage.com" width="100%" height="30000" frameborder="0" scrolling="no"></iframe>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well it is easy to do it in an iframe too -

    <html>
    <body onload="document.getElementById('iframe').scrollTo(500,500)">
    <iframe id="iframe" src="http://somewebpage.com" width="250" height="150"></iframe>
    </body>
    </html>

    Make sure the page height and width is over 500...

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by pcbrainbuster View Post
    Well it is easy to do it in an iframe too -

    <html>
    <body onload="document.getElementById('iframe').scrollTo(500,500)">
    <iframe id="iframe" src="http://somewebpage.com" width="250" height="150"></iframe>
    </body>
    </html>

    Make sure the page height and width is over 500...
    I don't think that will work even on the same domain and it certainly will not work across domains. To scroll the iframe, I think it needs to be addressed as a window object, not as a page element. Even if you do it as a window object, it must be on the same domain. Otherwise, it is a security violation.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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