Weird Thoughts From Eric's Head

Tags - Categories : All | AJAX | BUSINESS | PERSONAL | PROGRAMMING | BOOK REVIEW

AIA News Update: Dave's interview w/ indicthreads.com

Take a look at Dave Crane's interview here: http://www.indicthreads.com/content/view/359/0/1/0/. It is a really good article that you should enjoy reading.

Eric Pascarello
Coauthor of Ajax In Action
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for Dynamic Web Pages

JavaScript: Scroll to Bottom of a Div

UPDATE: check out the new version here: Allow user to scroll and maintain position with "Scroll To Bottom of the Div" example

I have seen the question asked on how do I scroll a div to the bottom for my Ajax based chat/ log/ news grabber/ etc. It is rather easy to do and involves a little bit of code utilizing scrollTop and scrollHeight.

var objDiv = document.getElementById("divExample");
objDiv.scrollTop = objDiv.scrollHeight;
Now if you have not noticed, the div below has been updating the time and it scroll position is at the bottom. Of course you would have to code some fancy stuff in it to take into account if the user has moved it and is reading it. I will leave it up to you to figure that out.

Hope that helps you out a little!

Eric Pascarello
Coauthor of Ajax In Action
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for Dynamic Web Pages