Results 1 to 6 of 6

Thread: Chat; scroll down new content

  1. #1
    Join Date
    Jul 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Chat; scroll down new content

    Hi,

    I have a chat script (type: shoutbox) that use ajax to get new content (messages) to a div, that works ok. However I'm looking for a way, that when a user type a message, the new message will scroll down from the top and push the other messages further down.

    regards,

    J

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Do you use a textarea, iframe, or what? Better yet, can we see your code online?
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. #3
    Join Date
    Jul 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's based on this script: http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    When I sumbit a message, it first goes to an iframe (hidden), the script on iframe-page inserts it to mysql and call the ajax-command (e.g. javascript:ajaxpage('test.htm', 'contentarea')) that loads/update the messages on page. So the message-page is inside a Div Layer.

    I have tried to use an iframe with anchors, so the iframe jumps down to the second message, and then scroll itself up to the top of the page, giving an illusion of "new message arriving at top, sliding down, and pushing the older messages under", but with it's loading and stuff, it wasn't such a good idea.

  4. #4
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Try this code:
    Code:
    function scrollToBottomOfDiv(divName) { 
    mydiv = document.getElementById(divName); 
    mydiv.scrollTop = mydiv.scrollHeight; 
    }
    Call it after the message appeared on the screen or else it will not work.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  5. #5
    Join Date
    Jul 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    A good example for my "wish-chat" is the Live-feed on Facebook, new message fades in from the top and push the rest downwards.

  6. #6
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    Is there any functionality you're asking for that is not animation? If it's just animation (the new message expanding, fading in), I think you need to look into a JS framework like JQuery.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

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
  •