PDA

View Full Version : javascript help needed




mnkeybsness
Mar 28, 2004, 01:16 AM
Hey everyone. I'm working on a webkit message view for adium2.0 and this is part of the default javascript for updating the window... when the window is updated, ie a user sends a message, the message is appended to the bottom of the page and then this function is called, checking if the window needs to be scrolled down. is it possible to change this to scroll an element (specifically some CSS--#Chat that has an overflow: auto; property)... basically, the element #Chat is smaller than the window and will scroll within its specified area and I want this javascript to scroll only that element and not the entire window. I really don't know much about javascript, other than this is the functions that matter for the scroll function...

thanks for your help.




function scrollToBottom() {
document.body.scrollTop = document.body.offsetHeight;
}

function checkIfScrollToBottomIsNeeded() {
scrollToBottomIsNeeded = ( document.body.scrollTop >= ( document.body.offsetHeight - ( window.innerHeight * 1.2 ) ) );
}

function scrollToBottomIfNeeded() {
if( scrollToBottomIsNeeded )
document.body.scrollTop = document.body.offsetHeight;
}