Hi people! I hope you can help me with this.
I want to execute the player() function in this code every few seconds(random)
How can I make the setTimeout() function wait before it continues?
The setTimeout() function is really useful. But it'll only run once, unless you start nesting it. You might want to try using the setInterval() function instead, because it'll run over and over again, at least until you clear the interval out.
I don't usually like referring people to w3schools, because the quality of the site needs to be evaluated on a per page basis with them. But, their setInterval() page is actually pretty good. http://www.w3schools.com/jsref/met_win_setinterval.asp
Hope that helps.
First of all, thanks for your help! However, as I understand it, the setInterval() function runs over and over again with the SAME number of millisecs between each run. However I want to have a random amount of time which is different between each and every execution! Is that possible with setInterval() ?
Originally Posted by epricity
I'm sorry man, I must have misread it.
Would something like this work?
It's a nesting solution to it, but the math looks about right.
This looks good! thanx man.
I will try to digest it when i am back home, since i dont understand what you did with round and curly brackets.
And i will report back when i got it working.
Actually, it's not mine. I don't remember when I found it, actually.
It's one that I bookmarked awhile back when I was trying to do something similar.
My snippet library is nuts these days. Something for every occasion.
Anyway, if you need any help with it, I'll be back online tonight-ish.
Good luck, man.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread