This is how I did it in the Client RC (copied/pasted directly out of the script):
PHP Code:
// Changed this so RC will scroll back to
// normal position. -Tig
// Store the old position before adding text
temp.oldpos = ScriptedRCScroll.scrollpos;
// Need to get the position of scroll when it's
// at the bottom
ScriptedRCScroll.scrollToBottom();
temp.maxscroll = ScriptedRCScroll.scrollpos[1];
ScriptedRCRCchat.text @= "\n" @ temp.data;
// If the scroll wasn't at the bottom, then don't
// scroll to back to the bottom.
if (temp.oldpos[1] != temp.maxscroll) {
ScriptedRCScroll.scrollTo(temp.oldpos[0], temp.oldpos[1]);
} else {
ScriptedRCScroll.scrollToBottom();
}
// Check to see if the text is bigger than the scroll
// viewing window, if not, scrolltobottom.
// Makes sure it will move the scroll down to the bottom
// if there was previously no scroll showing.
if (ScriptedRCRCchat.clientheight < ScriptedRCScroll.clientheight + ScriptedRCRCchat.profile.getTextHeight()) {
ScriptedRCScroll.scrollToBottom();
}