Javascript: Data che si aggiorna senza refresh

Va molto di moda mostrare all’interno di siti la data e l’ora corrente, create un testo a cui assegnare uno script di riferimento:

E poi inserite il seguente codice:

 
function OrologioScorrevole()
{
    var data = new Date();
    var hh = data.getHours();
    var mm = data.getMinutes();
    var ss = data.getSeconds();
    var ora = hh + ":" + mm + ":" + ss;
    document.getElementById("orologio").innerText = ora;
    window.setTimeout("OrologioScorrevole()", 1000);
}

Articoli simili

Lascia un commento

Your email is never published nor shared. Required fields are marked *

*
*

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a