Redirect with countdown

Redirect with countdown

To redirect user automatically after a fixed number of seconds is very simple with the following snippet.

<html>
    <head>
        <style type="text/css">
            span.contatore {
               font-size: 13px;
               font-weight:bold;
               cursor: default;
            }
        </style>
    </head>
<body>
    Tra 
    <span class="contatore" style="visibility:hidden;" id="DIV_REDIRECT">5</span>
    secondi verrai rediretto sulla home di codesnippet.it
</body>
<script language="javascript" type="text/javascript">

RedirectJS("http://www.codesnippet.it")

function RedirectJS(url){
   
   var objDiv = document.getElementById("DIV_REDIRECT");

   if(objDiv){

      objDiv.style.visibility = "visible";
      var cTicks = parseInt(objDiv.innerHTML);

       var timer = setInterval(function(){
					  if(cTicks){
						 objDiv.innerHTML = --cTicks;
					  }
					  else{
						 clearInterval(timer);
						 top.location.href = url;
					  }
					}, 1000);
   }
}
</script>
</html>

Download source: Redirect_con_conto_alla_rovescia.zip (660,00 bytes)

Redirigere automaticamente un utente dopo un certo numero di secondi non è mai stato così semplice.

Di seguito lo snippet che effettua un redirect con conto alla rovescia. Clicca Redirect_con_conto_alla_rovescia.html per vedere un esempio.

Oppure copia e incolla lo snippet!

<html>
    <head>
        <style type="text/css">
            span.contatore {
               font-size: 13px;
               font-weight:bold;
               cursor: default;
            }
        </style>
    </head>
<body>
    Tra 
    <span class="contatore" style="visibility:hidden;" id="DIV_REDIRECT">5</span>
    secondi verrai rediretto sulla home di codesnippet.it
</body>
<script language="javascript" type="text/javascript">

RedirectJS("http://www.codesnippet.it")

function RedirectJS(url){
   
   var objDiv = document.getElementById("DIV_REDIRECT");

   if(objDiv){

      objDiv.style.visibility = "visible";
      var cTicks = parseInt(objDiv.innerHTML);

       var timer = setInterval(function(){
					  if(cTicks){
						 objDiv.innerHTML = --cTicks;
					  }
					  else{
						 clearInterval(timer);
						 top.location.href = url;
					  }
					}, 1000);
   }
}
</script>
</html>

Download source: Redirect_con_conto_alla_rovescia.zip (660,00 bytes)

1 commento

comments user
marco

molto bello il tuo sito complimenti e anche interessante

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *