I am aware of the setInterval and setTimeout functions for Javascript, but
I can't seem to find an example that lets me do what I need to.

I have a script that needs to wait until a certain condition is met. In
this case, the condition is that an iframe has been reloaded completely. I
do this by examining a hidden document variable in the iframe, and when it
has changed from "" to "1" is the signal for me that the iframe is loaded.

(if there is an easier way to check this, please let me know. I am
otherwise not using frames, just one iframe).

What I need to do can be seen with this example function:

function saveFields() {
var str ;
if ( window.frames['ifrm'] ) {
while (window.frames['ifrm'].document.ifrmform.flag.value == "") {
// loop here until condition is met
}
// rest of code which should be performed AFTER condition is met
}
}

If I just let this run in my browser, the browser crashes, and I suppose
it is because all of its allotted CPU time is being used to check the
empty while loop. So I need a sleep function here, which will cause the
checking to wait, say, half a second each time. All I can see from the
setTimeout functions is that the function which calls them returns right
away, so I don't see how I can use that.

Any suggestions?

Thanks!
Steve, Denmark