PDA

View Full Version : Scrollable Content II: jump to end of content



lxndr
08-24-2006, 11:00 AM
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:


<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.

jscheuer1
08-25-2006, 07:20 AM
Add this function and line (red) as shown, near the end of the script:


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