Ajax help auto scroll to bottom

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Klown
Posts: 90
Joined: Tue Feb 22, 2011 5:59 am

Ajax help auto scroll to bottom

Post by Klown »

i am completely new to ajax, i found a small section of code on the net. I modified it to auto scroll to bottom during an interval. but i wish for user to have the ability to scroll up and content to still load without forcing to bottom. so if user is at bottom force bottom, if user is scrolling, dont force bottom just load content as usual.

this is for a simple chat script im making for my game.

Code: Select all

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
   setInterval(
   function(){
   $('#chat').load('loadchat.php');
   $("#chat").attr({ scrollTop: $("#chat").attr("scrollHeight") });
   }, 100);
</script>
the original script i found did not include: $("#chat").attr({ scrollTop: $("#chat").attr("scrollHeight") });
i added that in. so that it would scroll to bottom.

any suggestions would be appreciated.

-klown
if( $myGames != "Crap" ) {
  • please_donate( $money );
} else {
  • just_enjoy();
}
Post Reply

Return to “Beginner Help and Support”