neo_ludite
09-27-2002, 06:59 AM
This is a more compact view of the "open ad" code on yahoo.
<pre>
<script language=javascript>
// these are the two links for opening and closing the ad
var lnk1='<a href="#" onclick="moveIt(\'1\');return false">Open Ad</a>';
var lnk2='<a href="#" onclick="moveIt(\'0\');return false">Close Ad</a>';
// these are the contents of the table, you can put anything in here
var ad1='CLOSED STATE';
var ad2='OPEN STATE';
// this function actually moves the DIV size
function moveIt(status)
{
var tout=0;
if(status == '1')
{
lnkdiv.innerHTML=lnk2;
adstate.innerHTML=ad2;
if (document.all.addiv.style.pixelHeight<250)
{
document.all.addiv.style.pixelHeight=document.all.addiv.style.pixelHeight+5;
tout=setTimeout('moveIt('+status+')',1);
}
}
else
{
lnkdiv.innerHTML=lnk1;
adstate.innerHTML=ad1;
if (document.all.addiv.style.pixelHeight>=105)
{
document.all.addiv.style.pixelHeight=document.all.addiv.style.pixelHeight-5;
tout=setTimeout('moveIt('+status+')',1);
}
}
}
</script>
<table border="1"><tr><td><div id=addiv
style="position:relative;height:100;width:300;z-index:3"><div id=adstate>CLOSED
STATE</div></div></td></tr></table>
<div id=lnkdiv><a href="#" onclick="moveIt('1');return false">Open Ad</a></div>
</pre>
<pre>
<script language=javascript>
// these are the two links for opening and closing the ad
var lnk1='<a href="#" onclick="moveIt(\'1\');return false">Open Ad</a>';
var lnk2='<a href="#" onclick="moveIt(\'0\');return false">Close Ad</a>';
// these are the contents of the table, you can put anything in here
var ad1='CLOSED STATE';
var ad2='OPEN STATE';
// this function actually moves the DIV size
function moveIt(status)
{
var tout=0;
if(status == '1')
{
lnkdiv.innerHTML=lnk2;
adstate.innerHTML=ad2;
if (document.all.addiv.style.pixelHeight<250)
{
document.all.addiv.style.pixelHeight=document.all.addiv.style.pixelHeight+5;
tout=setTimeout('moveIt('+status+')',1);
}
}
else
{
lnkdiv.innerHTML=lnk1;
adstate.innerHTML=ad1;
if (document.all.addiv.style.pixelHeight>=105)
{
document.all.addiv.style.pixelHeight=document.all.addiv.style.pixelHeight-5;
tout=setTimeout('moveIt('+status+')',1);
}
}
}
</script>
<table border="1"><tr><td><div id=addiv
style="position:relative;height:100;width:300;z-index:3"><div id=adstate>CLOSED
STATE</div></div></td></tr></table>
<div id=lnkdiv><a href="#" onclick="moveIt('1');return false">Open Ad</a></div>
</pre>