www.webdeveloper.com
Results 1 to 2 of 2

Thread: if content of div is fully loaded

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    136

    if content of div is fully loaded

    Hello,

    I'm getting some content that contains images into a div via ajax. The div that these stuff gets load into has a height and overflow auto and I need to stick the scrollTop to the bottom like a messenger window.

    The problem is that when an image is not fully loaded, the height of the new content is not known, so that scrollTop confuses this and the scroll bar won't stick to the bottom. (or it sticks to the bottom but the change of the height after makes it jump to middle) The code I use is like this:

    Code:
    document.getElementById('main_div').scrollTop = 9999999;
    So before running that code, how do I make sure all the images are loaded as well or at least know the correct content height? (or any other workaround)

    Thanks

  2. #2
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    You can listen for 'load' events on the added images, and then update the scrollTop property in the event handler.

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