| L'HEURE DANS UNE FENETRE |
Outils pour webmaster. Trucs et astuces en code HTML et JavaScript : améliorer son site internet
Descriptif : vous affichez l'heure dans une fenêtre.
Mise en oeuvre : Sélectionnez et copiez directement à l'écran le code ci-dessous et collez-le dans votre page, code HTML visible.
Entre les deux balises <head> et </head>
| <!--
DEBUT DU SCRIPT --> <script language="JavaScript"><!-- // Helpers for JSI page... // Netscapes Clock - Start // this code was taken from Netscapes JavaScript documentation at // www.netscape.com on Jan.25.96 var timerID = null; var timerRunning = false; function stopclock (){ if(timerRunning) clearTimeout(timerID); timerRunning = false; } function startclock () { // Make sure the clock is stopped stopclock(); showtime(); } function showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() var timeValue = " " + ((hours >23) ? hours -23 :hours) timeValue += ((minutes < 10) ? "h0" : "h") + minutes document.clock.face.value = timeValue; // you could replace the above with this // and have a clock on the status bar: // window.status = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } // Netscapes Clock - Stop // end Helpers // --></script> <!-- FIN DU SCRIPT --> |
Dans la balise </body>
| onload="startclock()" |
Entre les deux balises <body> et </body>
| <!--
DEBUT DU SCRIPT --> <input type="text" size="6" name="face" align="left"> <!-- FIN DU SCRIPT --> |