should have posted this before - wait.html

-----------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd";>
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript"
src="/js/jquery.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
function wait(time){
  $("#test").css("display","block");
  time = time * 1000;
  var sleeping = true;
  var now = new Date();
  var startingMSeconds = now.getTime();
  while(sleeping){
    alarm = new Date();
    alarmMSeconds = alarm.getTime();
    if(alarmMSeconds - startingMSeconds > time){ sleeping = false; }
  }
}
//-->
</script>
<style type="text/css">
<!--
#test{
 display:none
}
-->
</style>
</head>
<body>
<div id="test">
WOW
</div>
<button type="button" onclick="wait(4);">wait</button>
</body>
</html>

------------------------------------------------ END EXAMPLE
-----------------


PragueExpat wrote:
> 
> Why does the following function wait until after the while loop is
> finished to update the #timer css? It happens in IE and Firefox  - I'm
> (still) using jQ 1.1.2.
> 
> function wait(time){
>   $("#timer").css("display","block");
>   time = time * 1000;
>   var sleeping = true;
>   var now = new Date();
>   var startingMSeconds = now.getTime();
>   while(sleeping){
>     alarm = new Date();
>     alarmMSeconds = alarm.getTime();
>     if(alarmMSeconds - startingMSeconds > time){ sleeping = false; }
>   }
> }
> 

-- 
View this message in context: 
http://www.nabble.com/I-thought-I-understood-threads...-tf4096371s15494.html#a11647892
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to