Ver Mensaje Individual
  #13 (permalink)  
Antiguo 29/05/2011, 00:45
elcapitolio
 
Fecha de Ingreso: mayo-2011
Mensajes: 167
Antigüedad: 12 años, 11 meses
Puntos: 1
Respuesta: Redireccionar con cuenta regresiva y con opcion de detener la redireccion

Tengo el siguiente codigo, pero no me funciona obviamente es por q no se mui bien de este lenguaje... me podrian ayudar...

Les recuerdo estoy tratando de que al dar click en botonparar aparezca un link en otra parte de la pagina

Código HTML:
var contador = function(tiempo, intervalo){
 var enCurso = 0, intv = intervalo || 1000;
 var veces = tiempo / intv, este = this, timer;
 this.empezar = function(callback){
  enCurso = 1;
  timer = setTimeout(function(){
   if(veces + 1 && enCurso){
    callback(veces-- * intv);
    setTimeout(function(){ este.empezar(callback); }, intv);
   }else{
    return enCurso = 0;
   }
  }, intv);
 };
 this.parar = function(){
  if(enCurso){ enCurso = 0; }
 };
}
var cuentaAtras = new contador(10000);
document.body.onload = function(){ cuentaAtras.empezar(function(tiempo){
 document.getElementById('cuenta').innerHTML = tiempo / 1000 ;
 if(!tiempo){ location.href = 'index2.php?lugar=<?php echo $_GET['lugar']; ?>'; }
 document.getElementById('botonparar').onclick = cuentaAtras.parar;
 if(!cuentaAtras.parar){ document.getElementById('vinculo').innerHTML = 'index2.php?lugar=<?php echo $_GET['lugar']; ?>'; }
}); }