PDA

View Full Version : Animated Collapsible DIV - autoclose in x seconds



doorock42
09-19-2007, 02:33 PM
1) Script Title: Animated Collapsible DIV

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

3) Describe problem: I would like to set the script to autoclose the div after it has been open for x seconds (or x milliseconds; I'm not picky). I'm not sure what to do -- my java skills are a bit limited. Perhaps someone has already done this and I can't find it on the forum.

Thanks.

doorock42
09-19-2007, 06:42 PM
Solved. This code is probably kludgy, but here it is:



<a href="#" onclick="javascript:collapse2.slideit()"><img src="javascript:ImageURL();" border="0" align="top" /></a>

<div id="ad" style="width: 920px; display:none;">
<img src="http://www.11alive.com/includes/art/ads/pr/ad_gassouth.gif" border="0" align="top" />
</div>

<script type="text/javascript">
//Syntax: var uniquevar=new animatedcollapse("DIV_id", animatetime_milisec, enablepersist(true/fase), [initialstate] )
var collapse2=new animatedcollapse("ad", 800, false)
function shortInterval()
{
self.setTimeout('collapse2.slideit()', 3000);
}
shortInterval();
</script>
<script type="text/javascript">
function longInterval()
{
self.setTimeout('collapse2.slideit()', 13000);
}
longInterval();
</script>


That will make the div appear after 3 seconds, then close up after about 10 more.

Suggestions for refinement welcome. I'm NOT a java programmer.