Home JavaScript Countdown con redirect in javascript

Countdown con redirect in javascript

368
0
Countdown movie from 5 to 0 number. Old film movie timer count in grey retro style. Vintage video timer, retro cinema animation.

Oggi vi propongo uno script che vi permette di avere un countdown che alla chiusura, cioe’ allo zero. crea un 301 quindi una redirect alla url che prestabiliamo.

Questo e’ lo script

<p>Tra <span id="seconds">7</span> secondi sarai redirizzato su digita.org.
</p>
var seconds = 7; // i secondi per HTML
var foo; // variabile per clearInterval() function
function redirect() {
    document.location.href = 'https://www.digita.org';
}
function updateSecs() {
    document.getElementById("seconds").innerHTML = seconds;
    seconds--;
    if (seconds == -1) {
        clearInterval(foo);
        redirect();
    }
}

function countdownTimer() {
    foo = setInterval(function () {
        updateSecs()
    }, 1000);
}

countdownTimer();>
Previous articlePHP e JSON
Next articleFeed di notizie RSS con PHP e MySQL

LEAVE A REPLY

Please enter your comment!
Please enter your name here