Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/05/2012, 07:28
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Contador de segundos? (no busco retardo)

Te dejo un timer sencillo que va guardando variables y ejecutando funciones cada n segundos (ó mili)
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.  
  7. <style type="text/css">
  8. /*<![CDATA[*/
  9.  
  10. button{
  11. width: 160px;
  12. }
  13. button.detener{
  14. margin-right: 8px;
  15. }
  16.  
  17. /*]]>*/
  18. <script type="text/javascript">
  19. //<![CDATA[
  20. var i = 0;
  21. var intval = "";
  22. var e = 0;
  23. var m;
  24. function miliseg(){
  25. document.getElementById('mili').innerHTML = i;
  26. if(e == 100){
  27. m = i;
  28. document.getElementById('mensajes').innerHTML = 'pasaron ' + m/10 + 'sgs.';
  29. e = 0;
  30. }
  31. e++;
  32. i++;
  33. }
  34.  
  35. function iniciar(){
  36. if(intval==""){
  37. intval=window.setInterval("miliseg()",100)
  38. }else{
  39. parar();
  40. }
  41. }
  42.  
  43. function parar(){
  44. if(intval!=""){
  45. window.clearInterval(intval);
  46. document.getElementById('inicia').innerHTML = 'continuar timer';
  47. intval="";
  48. }
  49. }
  50. //]]>
  51. </head>
  52. <div>
  53. <button id="inicia" onclick="iniciar();">iniciar timer</button> <button class="detener" onclick="parar();">detener timer</button>
  54. <span id="mili"><!-- contador --></span>
  55. <div>mensajes: <span id="mensajes"><!--- mensajes --></span></div>
  56. </div>
  57. </body>
  58. </html>

quizás puedas adaptarlo a lo que necesitas

SAludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.