PDA

View Full Version : collapsible div - general query



carlclancy
07-11-2008, 01:44 PM
1) Script Title: Animated Collapsible DIV v2.01

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.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.

Nile
07-11-2008, 08:03 PM
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.


<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>

ddadmin
07-11-2008, 09:27 PM
Regarding Nile's code, just as a correction, it should be:


<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.

Nile
07-11-2008, 09:38 PM
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

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?

ddadmin
07-11-2008, 09:52 PM
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.


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.

Nile
07-11-2008, 09:57 PM
Ahh, ok. I get it.

carlclancy
07-18-2008, 09:16 AM
thanks for the help, everyone. no doubt i'll be back for more!