Current location: Hot Scripts Forums » General Web Coding » JavaScript » Scroll to bottom of div with JavaScript


Scroll to bottom of div with JavaScript

Reply
  #1 (permalink)  
Old 04-08-09, 12:08 PM
kaceykeleher kaceykeleher is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Scroll to bottom of div with JavaScript

I'm currently working on a clients StoreFront site, and we are using jQuery tabs to open certain information at the bottom of their pages. Basically, it tells pricing and has samples in two different tabs. As of now, if you click a tab, it opens and does not scroll to the very bottom, so there's like an inch of space they have to scroll to view it all. I'm interested in having it so that when a viewer clicks the tab, it will automatically scroll to the bottom so they do not have to scroll down to view it all.

This is what I have so far:

Code:
<script type="text/javascript">
	function toBottom(event)
	{
		var objControl=document.getElementById("audio");
		objControl.scrollTop = objControl.scrollHeight;
	}
</script>
HTML Code:
<li><a href="#audio" onClick="toBottom()"><span>Audiobook</span></a></li>
Then I have a div at the bottom of each section with an id of 'bottom' but this does not seem to work. Does anyone have any idea how I could possibly make this work?
__________________
"Where's that Peter Griffin? He told me he'd give me a hundred fifty bucks if I took off all my clothes off." - Peter Griffin, Family Guy

W3Schools - You'll be surprised what you can learn on your own!
Reply With Quote
  #2 (permalink)  
Old 04-08-09, 03:36 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Why you have that div with id="bottom" when the script only uses an element with the id 'audio'.

That script should however scroll the 'audio' div to the bottom, as long as it has the height set.
It would be a lot easier to test what actually happens if you provide either a link to the actual page, or the complete code.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
  #3 (permalink)  
Old 04-08-09, 04:03 PM
kaceykeleher kaceykeleher is offline
Newbie Coder
 
Join Date: Mar 2009
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
That's as much of the code as I can give out. For privacy purposes I am not allowed to provide everything, nor a link to the page. It is password protected and only certain people are allowed access at this time.

Can anyone provide a way to make that script work, or perhaps suggest another that may work for us?
__________________
"Where's that Peter Griffin? He told me he'd give me a hundred fifty bucks if I took off all my clothes off." - Peter Griffin, Family Guy

W3Schools - You'll be surprised what you can learn on your own!
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
[SOLVED] delay on html element properties? UnrealEd JavaScript 5 05-05-08 03:23 AM
go to the bottom of div funny_shrshr JavaScript 2 11-14-06 04:56 AM
DIV background (top & bottom images) overlapping? sp1ky CSS 1 11-12-06 10:53 AM
how to create scroll bar ,using javascript DOM deepraj JavaScript 1 12-29-05 02:03 AM
JavaScript Scroll help... Thomas82 JavaScript 1 04-30-05 08:42 AM


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