|
-
June 21st, 2011, 07:48 PM
#1
Keep div scrollbar scrolled to bottom at all times
I have a bunch of information relayed to a multi-line text box from a websocket and I want my div overflow scrollbar to scroll to the bottom everytime a new line of information is recieved. The code I am using apparently works for everyone else but does not do anything for me. Any suggesions?
Code:
<script type="text/javascript">
var objDiv = document.getElementById("container");
objDiv.scrollTop = objDiv.scrollHeight;
</script>
<div id="container" style="border: solid; width: 70%; height: 50%; border-color: #333333; margin: 0 auto; overflow: auto; ">
<div id="console_wrapper">
<pre id="console"></pre>
<input type="text" name="console_input" id="console_input" value="" />
<input type="submit" name="console_send" id="console_send" value="Send" />
<input type="submit" name="console_quit" id="console_quit" value="Quit" />
</div>
-
June 22nd, 2011, 07:59 AM
#2
Re: Keep div scrollbar scrolled to bottom at all times
Use scrollTo(0, 99999); instead.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 22nd, 2011, 10:07 PM
#3
Re: Keep div scrollbar scrolled to bottom at all times
I am not that gifted with javascript. Do you mean like this?
Code:
<script type="text/javascript">
document.getElementById("container").scrollTo(0, 99999);
</script>
-
June 23rd, 2011, 06:56 AM
#4
Re: Keep div scrollbar scrolled to bottom at all times
Ah...I read your first post incorrectly and was thinking you were using an <iframe>.
The code you have is correct. However, you need to implement it everytime data is sent/received. As you have it now, you're attempting to run it before the form and it's container is even loaded.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|