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 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    positioning in iframe page

    Hello

    I am building a small messenger and I am using three iframes. One for displaying the messages and one for entering the messages and one hidden iframe for polling.

    I want the lines in the display window to scroll up and than position at the bottom (so the last message is at the last line and visible)

    How do I do that? (I dont want to use the <A name=... Anchor for jumping to the bottom after reloading the display window.)
    Fred

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can try using the scrollTo() method:
    http://www.devguru.com/Technologies/..._scrollto.html

    The next question may be: what values do I pass to scrollTo() (like where's the bottom going to be necessarily?)

    I'm not too sure how it would work, but my guess might be to find out how big the body area is, and then scroll to that Y-value. Just my guess, I've never tried it..

    Mess around with it and see if you can get it to go. Perhaps in the meanwhile someone with the knowledge can advise you better.

    Good luck,
    Sadiq.

  • #3
    Regular Coder
    Join Date
    Jun 2004
    Posts
    565
    Thanks
    0
    Thanked 18 Times in 18 Posts
    You could use window.innerHeight / document.body.offsetHeight in conjuction with window.scrollTo(), e.g.:

    if(document.all) window.scrollTo(0, document.body.offsetHeight);
    else window.scrollTo(0, window.innerHeight);

    Note: You can use this only if the body-tag was already loaded so it would make sense to start the execution of the function with the onload-event.
    Last edited by dumpfi; 06-30-2004 at 11:07 PM.

  • #4
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The option Sad69 offered suited best for me. I've build this small function which runs at onload.

    function toBottom() {
    self.scrollTo(0, 9999999)
    }

    It works fine with ie6 do some of you expect problems with other browsers?
    Fred

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,074
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I think this is better:

    function toBottom() {
    self.scrollTo(0, document.body.scrollHeight);
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New Coder
    Join Date
    Oct 2003
    Location
    The Netherlands
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you I also like this better.
    Fred


  •  

    Posting Permissions

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