Jump to content

timing script events


Xeron
 Share

Recommended Posts

I'm trying to delay a part of my code. The part what needs to be delayed for x seconds is is requesting content from a daemon. However the delay cannot cause other part of the script to stop.The part I want to delay is within a function in a try { } statement. only this part needs to be delayed. I tried a setTimeout however the function called 1 line earlier also stops working. The function does not execute fully before the settimeout is triggered.function(1) { callfunction(2); // Delayed codetry{ socket.send(sendcmd); log('sencmd); } }// End delayed code }maybe someone has any idea how to manage this? thanks!!

Edited by Xeron
Link to comment
Share on other sites

im not sure I get what is going wrong for you, I tried some timeouts and none of them interupted each other or stopped the function from completeing

<html><head><script type="text/javascript">function test(){setTimeout(function(){  document.getElementById("delay1").innerHTML = "delay 1..";}, 4000);setTimeout(function(){  document.getElementById("delay2").innerHTML = "delay 2..";}, 3000);document.getElementById("endOfFunction").innerHTML = "function ending...";}</script></head><body onload="test();"><p id="delay1"></p><p id="delay2"></p><p id="endOfFunction"></p></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...