Results 1 to 2 of 2

Thread: Scrollable Content II: jump to end of content

  1. #1
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Scrollable Content II: jump to end of content

    1) Script Title: Scrollable Content II

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex11/scrollc2.htm

    3) Describe problem:

    I have this script working and am using it to scroll through messages in a Shoutbox php program I am writing. The Shoutbox consists of an html table with a series of comments from different users. These are read from an SQL table and output as html table rows. What I would like to be able to do though is automatically scroll to the most recent entry, i.e. suppose the following is output:

    Code:
    <table>
    <tr><td>Comment 1</td></tr>
    <tr><td>Comment 2</td></tr>
    <tr><td>Comment 3</td></tr>
    <tr><td>Comment 4</td></tr>
    <tr><td>Comment 5</td></tr>
    </table>
    etc.

    If we imagine the table rows with Comment 4 and Comment 5 are not visible until the user has scrolled down, I would like the script to automatically go to the last table row, ie Comment 5. Is there any way I could modify the script to do this?

    Thanks for any help.

  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

    Add this function and line (red) as shown, near the end of the script:

    Code:
    function moveup(){
    if (iens6&&parseInt(crossobj.style.top)<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
    else if (ns4&&crossobj.top<=0)
    crossobj.top+=speed
    moveupvar=setTimeout("moveup()",20)
    
    }
    
    function movedownfast(){
    if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100)){
    crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
    movedownfast();
    }
    else if (ns4&&crossobj.top>=(contentheight*(-1)+100)){
    crossobj.top-=speed
    movedownfast();
    }
    }
    
    function getcontent_height(){
    if (iens6)
    contentheight=crossobj.offsetHeight
    else if (ns4)
    document.nscontainer.document.nscontent.visibility="show"
    movedownfast();
    }
    window.onload=getcontent_height
    - 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
  •