Div overflow start scrolled all the way to the bottom on load
7 replies, posted
I'm trying to coda a chatbox and I need the scrollbar to start scrolled all the way down to where the most recent chats are. Any idea how I can get a div overflow to start scrolled all the way on the bottom when the page loads? I've tried adding html anchors but that brings the whole page down instead of just the div scroll. I think I could fix that problem using an iframe but that seems like a nub solution. I'm pretty sure it can be done with javascript, but I don't know much/any.
Add to the end of your MySql query "ORDER BY id DESC"
Yeah, I thought of doing that but that's a nub solution too. I want it to seem more like an irc or AIM chat so you dont have to read upwards. Thanks for your input tho,
[code]
var objDiv = document.getElementById("Your div ID here.");
objDiv.scrollTop = objDiv.scrollHeight;
[/code]
I believe this should do the trick. I haven't tested it though.
It's Javascript btw.
[QUOTE=Fear_Fox;28177850][code]
var objDiv = document.getElementById("Your div ID here.");
objDiv.scrollTop = objDiv.scrollHeight;
[/code]
I believe this should do the trick. I haven't tested it though.
It's Javascript btw.[/QUOTE]
Thanks that worked great!