View Full Version : Animated Collapsing Div's

04-06-2008, 01:50 PM
1) Script Title:
Animated Collapsing Div's

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem:
Hi, first of all thanks for this script. Its awesome, so sweet being able to watch your content slide away so tidily!

So heres the problem, the script saves each page as a seperate unique id, so if I have the same boxes showing on different pages, such as a login which appears in every page. It doesnt remember it for all pages displaying the login.

Is there anyway to change this script so that it remembers this? I only going to use it for the single login section, just so if people want to hide it they can but I want it to remember for each page in the site as a whole, and not as seperate pages, how do I do that?

Thanks for any help in advance.


04-06-2008, 08:31 PM
Try changing the below two lines in the .js file, by removing the parts in red:

this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value

animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")

Then, modify the below line near the bottom, by adding to it the part in red:

document.cookie = name+"="+value+';path=/'

That should do it.

04-06-2008, 10:19 PM
Hi, I made those changes just inside the default script and created an identical page with the same div, but it doesnt store, it still collapses (as default)...

I have tried this on a live server and not from my computer of course.

Any ideas?

04-06-2008, 10:50 PM
Sorry to be a pain, but also, is there anyway to make it store for longer than the current session? For example, 7 days after (so long as cookies arent reset)?

If this is possible without too much hassle it would be perfect for my forum (when I have time to do it!)

Thanks again.


04-07-2008, 11:26 AM
It does work today, sorry, it must have been running for cache or something, it seems to work fine today with storing it as a single reference and not each page as unique. Great!

Is there anyway to store it for any longer than the current session?

Also: I cant get it to start opened, I have added the "block" as the last reference in the javascript but it doesnt seem to do anything. They all start closed unless I set the options to false, "block", but then it doesnt store whether they are open or closed...

Any help?

04-08-2008, 04:58 AM
Regarding issue #1 above, please post a link to the page on your site that contains the problematic script so we can check it out. For #2, you can make the cookie persistent and for x number of days by making the changes in red to the line "document.cookie=..." above:

var expireDate = new Date()
document.cookie = name+"="+value+";path=/"+";expires="+expireDate.toGMTString()

Where 3 means 3 days.