Go Back   Dynamic Drive Forums > DD Scripts > Dynamic Drive scripts help
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-11-2008, 02:44 PM
carlclancy carlclancy is offline
New Comer (less than 5 posts)
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default collapsible div - general query

1) Script Title: Animated Collapsible DIV v2.01

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...edcollapse.htm

3) Describe problem:

this is a general question rather than a problem, which i need to know the answer to before beginning working with this script.

is it possible to get this script to automatically execute a number of seconds after a page loads? i'd like a div to collapse to a third of its height say 5 seconds after the page loads.

thanks in advance.
Reply With Quote
  #2  
Old 07-11-2008, 09:03 PM
Nile's Avatar
Nile Nile is offline
Elite Coders
 
Join Date: Jan 2008
Posts: 3,007
Thanks: 10
Thanked 442 Times in 438 Posts
Blog Entries: 5
Default

I don't know if you can get it to collapse a third of its height, but you can get it to expand 5 seconds after the page loads. Find the red code below in your html, and add the blue.
Code:
<script type="text/javascript" src="animatedcollapse.js">

/***********************************************
* Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

window.onLoad=setTimeout("animatedcollapse.show(['jason', 'kelly', 'michael']);",5000);

</script>
__________________
Coding is just another puzzle. And it's okay to have help putting together some peices.
Please don't be afraid to ask.
I try to highlight my code with correct syntax highlighting. Unless the its too long. Or I'm to busy.
Reply With Quote
  #3  
Old 07-11-2008, 10:27 PM
ddadmin's Avatar
ddadmin ddadmin is offline
Administrator
 
Join Date: Aug 2004
Posts: 7,626
Thanks: 2
Thanked 639 Times in 629 Posts
Blog Entries: 13
Default

Regarding Nile's code, just as a correction, it should be:

Code:
<script type="text/javascript" src="animatedcollapse.js">

/***********************************************
* Animated Collapsible DIV v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

<script type="text/javascript">
window.onLoad=setTimeout("animatedcollapse.show(['jason', 'kelly', 'michael']);",5000);
</script>
To add my two cents, there's no easy way to have a DIV collapse or expand midway unfortunately.
Reply With Quote
  #4  
Old 07-11-2008, 10:38 PM
Nile's Avatar
Nile Nile is offline
Elite Coders
 
Join Date: Jan 2008
Posts: 3,007
Thanks: 10
Thanked 442 Times in 438 Posts
Blog Entries: 5
Default

A question, not an argument: Whats the difference between putting the onload in a different script section? Why can't you just put it in the first one?
@ddadmin
Quote:
Originally Posted by ddadmin View Post
To add my two cents, there's no easy way to have a DIV collapse or expand midway unfortunately.
I've thought about this, and I wonder is it possible to set the height in the show function. And with that the JavaScript would give it a max-height?
__________________
Coding is just another puzzle. And it's okay to have help putting together some peices.
Please don't be afraid to ask.
I try to highlight my code with correct syntax highlighting. Unless the its too long. Or I'm to busy.
Reply With Quote
  #5  
Old 07-11-2008, 10:52 PM
ddadmin's Avatar
ddadmin ddadmin is offline
Administrator
 
Join Date: Aug 2004
Posts: 7,626
Thanks: 2
Thanked 639 Times in 629 Posts
Blog Entries: 13
Default

Quote:
A question, not an argument: Whats the difference between putting the onload in a different script section? Why can't you just put it in the first one?
Well, since the first script is an external JavaScript reference, anything you put inline between the SCRIPT tags get replaced/ignored, hence the need for the second SCRIPT.

Quote:
I've thought about this, and I wonder is it possible to set the height in the show function. And with that the JavaScript would give it a max-height?
I should have been more clear. It's not hard to have a DIV in general to collapse/expand midway instead of completely, but integrating that into the script without breaking the default behavior is where things get more complicated. Right now the script just uses jQuery's slideDown() and slideUp() function for its animations, which would need to be replaced.
Reply With Quote
  #6  
Old 07-11-2008, 10:57 PM
Nile's Avatar
Nile Nile is offline
Elite Coders
 
Join Date: Jan 2008
Posts: 3,007
Thanks: 10
Thanked 442 Times in 438 Posts
Blog Entries: 5
Default

Ahh, ok. I get it.
__________________
Coding is just another puzzle. And it's okay to have help putting together some peices.
Please don't be afraid to ask.
I try to highlight my code with correct syntax highlighting. Unless the its too long. Or I'm to busy.
Reply With Quote
  #7  
Old 07-18-2008, 10:16 AM
carlclancy carlclancy is offline
New Comer (less than 5 posts)
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the help, everyone. no doubt i'll be back for more!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:14 PM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.