Current location: Hot Scripts Forums » General Web Coding » JavaScript » go to the bottom of div


go to the bottom of div

Reply
  #1 (permalink)  
Old 11-14-06, 02:18 AM
funny_shrshr funny_shrshr is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy go to the bottom of div

hi all of you , it's my first post to you ..... and i'm really need help .I make a chat component and show the chat history in a div which is always refreshed and i want to make it always go to bottom , I use this code

document.getElementById("div_name").scrollTop=docu ment.getElementById("div_name").scrollHeight;

it works successfully on mozilla but not on explorer

thank you and happy day
Reply With Quote
  #2 (permalink)  
Old 11-14-06, 02:41 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
This should do it.
Code:
<script type="text/javascript">

var div = document.getElementById("div_name");
var y = (div.scrollHeight > div.offsetHeight) ? div.scrollHeight : div.offsetHeight;

div.scrollTop = y;

</script>
http://www.quirksmode.org/viewport/compatibility.html
Reply With Quote
  #3 (permalink)  
Old 11-14-06, 04:56 AM
funny_shrshr funny_shrshr is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
thank you Nico , it works well
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Div Scrolling dwoody CSS 2 12-28-06 07:59 PM
DIV background (top & bottom images) overlapping? sp1ky CSS 1 11-12-06 10:53 AM
Can't Understand java script maverickminds JavaScript 1 07-16-06 01:23 PM
expanding a div to keep image contained pukington HTML/XHTML/XML 0 12-26-05 08:04 AM
CSS Div problem themanmathias CSS 1 09-29-05 08:05 PM


All times are GMT -5. The time now is 11:21 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.