473,394 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Repeat with pause

Hi there,

First off thank you for reading.

I'm trying to get the following to work.
I want a script that does the following 9 times: jah(urlOne); and then
1 time: jah(urlTwo); then it should start at the top again.
There has to be a break in between, thats why i have the wait function
there.
Hope anybody can help me because i'm not seeing my mistake and can't
think clear any more.

Thank you for reading.

<script language="javascript" type="text/javascript">
var urlOne="messageCenter.php, msgOne";
var urlTwo="messageBanner.php, msgOne";
var waitTime="1000";

alert (urlOne);

function wait(msecs)
{
var start = new Date().getTime();
var cur = start
while(cur - start < msecs)
{
cur = new Date().getTime();
}
}
alert (urlOne + " voor de statment");
jah(urlOne);
alert (urlOne + " na de statment");
wait(waitTime);

</script>

Mar 22 '08 #1
2 1396
"ZT**********@gmail.com" <ZT**********@gmail.comwrites:
Hi there,

First off thank you for reading.

I'm trying to get the following to work.
I want a script that does the following 9 times: jah(urlOne); and then
1 time: jah(urlTwo); then it should start at the top again.
There has to be a break in between, thats why i have the wait function
there.
Hope anybody can help me because i'm not seeing my mistake and can't
think clear any more.
You've not explained what's going wrong.

Anwyay:
function wait(msecs)
{
var start = new Date().getTime();
var cur = start
while(cur - start < msecs)
{
cur = new Date().getTime();
}
}
NEVER EVER DO THAT. It will use up 100% of your CPU and probably will
block your host (browser) completely until the timeout is
finished. Possibly the host will break your script to prevent that.

Use setTimeout() instead; something like:

var count = 0;
function nineTimes() {
if (count++ < 9) {
jah(urlOne);
setTimeout(nineTimes, 1000);
}
else {
setTimeout(function() { jah(urlTwo) },1000);
}
}
nineTimes();
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Mar 22 '08 #2
Thank you all 3 of you, i'm amazed by the answer and the speed the
were provided in.
Will post my code and the site when i'm done.

Thanks again!

Gr,

Jeroen
Mar 23 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew | last post by:
When will .NET have a low-pause-time garbage collector A low-pause-time garbage collector would greatly improve .NET's ability to serve as a platform for soft real-time systems. It doesn't have...
5
by: Brian.Steele | last post by:
Greetings everyone. See http://www.spiceisle.com/cgi-bin/slideshow/slideshow.cgi?dir=brian/personal/2005/uk_trip/images&type=jpg The "Pause" button works in IE, but not in Firefox. Any ideas...
11
by: Paminu | last post by:
Is there something like system("PAUSE") for linux?
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
38
by: Jackie | last post by:
I just want the programme to stop for a while. Thanks.
2
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to start, pause and resume a recurrsive search exactly where you left off, say in the registry programmatically? -- Michael Bragg,...
6
by: Peted | last post by:
Hi wondering what is the best way to do this Need a user to click a button, that sends 3 or 4 string based commands via a TCP/ip socket link I can connect to the ip device no problems, am...
8
by: Lloydm | last post by:
I've used the command "pause" in batch files which works ok but I guess it's applied dirrently in c++. Using Dev C++ 4.0 and the following is my code #include<iostream> #include<iomanip>...
3
by: garfunkel214 | last post by:
I have images and text rotating every 7000 ms using a setInterval. i am trying to implement a pause button that will stop the rotation when clicked. When clicked once more, I would like the rotation...
2
by: bmerlover | last post by:
How do I use a PAUSE in .NET Framework using C++ (Visual Studio .NET 2003). I know it's system("pause") in the dos version. But I don't know what it is in the GUI version. I tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.