[Javascript] Wait for a delayed function to end to start another...

Peter Brunone peter at brunone.com
Wed Jan 24 12:46:38 CST 2007



   What about another global variable that flips before when you call setTimeout, and resets when the function actually runs?

				From: Guillaume javascript at webdesignofficina.com

I have two functions showing / hiding layer, each one with a different 
delay.
Each function is fired with it's individual link: Show ( ShowDelayed() ) 
// Hide ( HideDelayed() )
How do I avoid these function of running together, at the same time, if 
a user clicks alternatively on the two links for example...
Each function should first end before the other one starts running...

I have to achieve this inside the script and can't use a delayed onclick 
for example...

Don't know if this is clear... Have a rough example below...

Regards,
Guillaume

var HideChk = false;

function Hide() {
if (HideChk) return;
HideChk = true;
var opts1 = document.getElementById("options");
opts1.style.display = "none";
}

function HideDelayed() {
setTimeout('Hide()',6000)
}

var ShowChk = false;

function Show() {
if (ShowChk) return;
ShowChk = true;
var opts1 = document.getElementById("options");
opts1.style.display = "block";
}

function ShowDelayed() {
setTimeout('Show()',3000)
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20070124/928068c5/attachment.htm>


More information about the Javascript mailing list