function scrollToBottom() { var objDiv = document.getElementById("message"); objDiv.scrollTop = objDiv.scrollHeight; }
<div id="message" önload="scrollToBottom()" > <ul> @foreach(var row in db.Query("SELECT * FROM Messages WHERE (FromUserID= @0 AND ToUserID= @1) OR (FromUserID= @1 AND ToUserID =@0)",id,WebSecurity.CurrentUserId)) { if(row.FromUserID==id) { var a= db.QuerySingle("SELECT * FROM UserProfile WHERE UserId=@0",row.FromUserId); <li > <span id="messageToMe">@a.User</span> <br>@row.Message </li> } else { <li > <span id="messageFromMe">@WebSecurity.CurrentUserName</span> <br> @row.Message </li> } } </ul> </div>
#message { float: right; overflow: auto; position: relative; border-bottom: 1px solid black; height: 280px; width: 450px; }
window.onload=function () { var objDiv = document.getElementById("MyDivElement"); objDiv.scrollTop = objDiv.scrollHeight; }
document.getElementById('message').scrollTop = 9999999;
Quote:The scrollTop property specifies the scrolling offset in pixels from the top of the region. Setting it to a very large value will force it to the bottom.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)