View Full Version : setTimout() with expanding <div>
Antoniohawk
03-22-2003, 07:37 AM
i cant figure out how to make this script work. I want a <div>'s height to grow larger as time goes by, after i click a link, then stop at a certain height. Wats wrong with my script? Any help that some1 could provide would b greatly appreciated.
height = document.all.menu.style.height=100+"px";
function movemenu(){
height = height++;
if(document.layers){
document.menu.left=height;
}
if(document.all){
document.all.menu.style.left=height;
}
if(!document.all && document.getElementById){
document.getElementById("menu").style.left=height+"px";
}
if (height>=-screen.height){
window.clearTimeout(Id);Id=0;
}else{
Id = window.setTimeout("movemenu();",100);
}
}
- - - - -
<div id="menu"></div>
<a href="#" onClick="movemenu();" return false>Go</a><BR>
Have a play with the following
<script>
function init(){
height = parseInt(document.all.menu.style.height)
movemenu()
}
function movemenu(){
height += 10;
if(document.layers){
document.menu.height=height;
}
if(document.all){
document.all.menu.style.height=height;
}
if(document.all && document.getElementById){
document.getElementById("menu").style.height=height
}
if (height>=screen.height-200){
window.clearTimeout(Id)
}
else{
document.getElementById("menu").style.height=height
Id = setTimeout("movemenu()",50);
menu.innerText=document.getElementById("menu").style.height
}
}
</script>
<a href="#null" onClick="init()">Go</a><BR>
<div id="menu" style="border:1 solid black;background-color:red;height:100;width:100"></div>
Antoniohawk
03-23-2003, 10:47 PM
thx for the great script, 1 problem tho, look at wat happens.
htttp://www.angelfire.com/games4/guidetorune/calc/test.html
Antoniohawk
03-24-2003, 05:31 AM
still having probs can some1 help me?
In the link code you have nothing in the link quotes
<a href="" onClick="init()" return false>Go</a><BR>
It should be
<a href="#null" onClick="init()">Go</a><BR>
Antoniohawk
03-24-2003, 11:38 PM
tried that but still no go :(
HI
I have just been to
www.angelfire.com/games4/guidetorune/calc/test.html#null
I clicked on the GO link and the red DIV's height changed and eventually stopped without trying to load another page.
I thought this is what you wanted it to do?
Please explain more
:thumbsup:
Antoniohawk
03-26-2003, 04:00 AM
ive figured out that alot of things go really weird when u preview them while ur coding at angelfire. If you actually save the file then go to the site, it works just fine. Thats pretty much wat my problem was i guess. Thx alot for ur help.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.