How to move the div's scroll to bottom?

Posted on 2007-07-28
Last Modified: 2010-05-18
How to move the div's scroll to bottom?
Question by:apnamian
    1 Comment
    LVL 14

    Accepted Solution

    Try this....

    var objDiv = document.getElementById("divExample");
    objDiv.scrollTop = objDiv.scrollHeight;


    var mydiv = document.getElementById("mydiv");
    mydiv.scrollTop = mydiv.scrollHeight - mydiv.clientHeight;


    <BODY onLoad="document.getElementById('news').scrolltop=document.getElementById('news').scrollHeight-document.getElementById('news').clientHeight">
    <div style="overflow:auto;width:200px;height:300px;border:1px solid black;font-size:10px;font-family:arial" id="news">Event 1<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br>Event 2<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br>Event 3<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br>Event 4<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br>Event 5<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br>Event 6<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br>Event 7<br><br><BLOCKQUOTE>Blah blah blah</BLOCKQUOTE><br><br></DIV>

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    CSS/audio questions 2 42
    Summernote required 3 21
    How can I see the value of the "object" 10 19
    Grunt No Clean Targets 6 13
    This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now