Code:
function scroller()
{
	var container = document.getElementById("chatbox");
	var maxTop = container.scrollHeight - container.clientHeight;
	var aoe = container.scrollHeight - container.clientHeight - 150;
	
		if(container.scrollTop < aoe)
		{
			//leave this blank i guess  O_o
		}
		else
		container.scrollTop = maxTop;
}
just call it whenever you want to put some input in a div or whatever. It'll keep the scroll bar at the bottom of the page if it's within range of the bottom. Works perfect in my chatroom app.