Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/05/2009, 11:48
Avatar de alor86
alor86
 
Fecha de Ingreso: abril-2009
Mensajes: 110
Antigüedad: 15 años, 1 mes
Puntos: 5
Respuesta: ¿window.setTimeout dentro de un while?

<head>

<meta name="author" content="alor86" />
<script type="text/javaScript">
var a=2;
var intervalo;

function restar(){
intervalo=setInterval(res,2000);
}
function res(){
if(a>=0){
var r = document.getElementById('r');
a-=Math.random();
r.innerHTML+="valor de a es==>"+a+"<br/>";
}
else{
clearInterval(intervalo);
}
}
</script>
<title>resta</title>
</head>

<body onload="restar();">
<div id="r">

</div>


</body>
</html>
prueba asi