
March 5th, 2006, 04:06 AM
|
|
|
|
Join Date: Apr 2007
Posts: 34
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
javascript not waiting for function return
and I didn't think it was possible...
does javascript not execute sequentially? I think not. I have a simple script:
Code:
function fade_about_out() {
document.getElementById('about').style.MozOpacity -= .1;
if(document.getElementById('about').style.MozOpaci ty < .1)
{
document.getElementById('about').style.display='no ne';
return;
}
setTimeout(fade_about_out, 20);
}
function fade_design_in() {
document.getElementById('design').style.MozOpacity += .1;
if(document.getElementById('design').style.MozOpac ity > 1)
{
return;
}
setTimeout(fade_design_in, 20);
}
function show_design() {
//hide about
document.getElementById('about').style.MozOpacity = 1;
fade_about_out();
//show design
document.getElementById('design').style.MozOpacity = 0;
document.getElementById('design').style.display='' ;
fade_design_in();
}
the 'fade_design_in' executed before 'fade_design_out' returns! how can this be possible?
many thanks for any help; I'm exausted..
g-
|