Results 1 to 7 of 7

Thread: collapsible div - general query

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

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    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>
    Jeremy | jfein.net

  3. #3
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    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.

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    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?
    Jeremy | jfein.net

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

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

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ahh, ok. I get it.
    Jeremy | jfein.net

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •