Créez un nouveau fichier texte, copiez le code suivant dans et modifiez le nom du fichier en horloge.html et exécutez-le.
<Script Language = JavaScript> <! - dcol = '0000ff'; // Couleur de date. fcol = '0000ff'; // couleur face. SCOL = '0000FF'; // Couleur de secondes. MCOL = '0000FF'; // Couleur de minutes. HCOL = '0000FF'; // Couleur d'heures. ClockHeight = 40; ClockWidth = 40; ClockFrommousey = 0; ClockFrommousex = 100; // ne modifie rien ci-dessous! Les alignements seront perdus! D = New Array ("Sunday", "Monday", "Mardi", "Mercredi", "Jeudi", "Friday", "Saturday"); M = New Array ("janvier", "février", "March", "April", "May", "June", "Juillet", "August", "Septembre", "Octobre", "Novembre", "décembre"); date = new Date (); day = date.getDate (); année = date.getyear (); si (année <2000) année = an + 1900; TodaysDate = "" + d [date.getDay ()] + "" + Day + "" + m [date.getMonth ()] + "" + année; D = TodaySdate.Split (''); H = '...'; H = H.Split (''); M = '....'; M = M.Split (''); S = '.....'; S = s.split (''); Face = '1 2 3 4 5 6 7 8 9 10 11 12'; Font = 'Arial'; taille = 1; vitesse = 0,5; ns = (document.layers); ie = (document.all); Face = face.split (''); n = face.length; a = taille * 10; ymouse = 0; xmouse = 0; scrll = 0; props = "<font face =" + font + "size =" + size + "color =" + fcol + "> <b>"; props2 = "<font face =" + font + "size =" + size + "color =" + dcol + "> <b>"; Split = 360 / N; Dsplit = 360 / d.Length; HandHeight = ClockHeight / 4.5 HandWidth = ClockWidth / 4.5 Handy = -7; Handx = -2,5; scrll = 0; étape = 0,06; currsep = 0; y = new Array (); x = new Array (); y = new Array (); x = new Array (); pour (i = 0; i <n; i ++) {y [i] = 0; x [i] = 0; y [i] = 0; x [i] = 0} dy = new Array (); dx = new Array (); dy = new Array (); dx = new Array (); pour (i = 0; i <d.Length; i ++) {dy [i] = 0; dx [i] = 0; dy [i] = 0; dx [i] = 0} if (ns) {for (i = 0; i <d.length; i ++) document.write ('<yer name = "nsdate' + i + '" top = 0 Left = 0 height =' + a + ' width = '+ a +'> <enter> '+ Props2 + d [i] +' </font> </ Center> </ Layer> '); pour (i = 0; i <n; i ++) document.write ('<coucheer name = "nsface' + i + '" top = 0 Left = 0 height =' + a + 'width =' + a + '> <enter>' + props + face [i] + '</font> </ Center> </poseer>'); pour (i = 0; i <s.Length; i ++) document.write ('<coucheer name = nsseconds' + i + 'top = 0 Left = 0 width = 15 height = 15> <font face = arial size = 3 color =' + scol + '> <enter> <b>' + s [i] + '</b> </ender> </font> </ caler>'); pour (i = 0; i <M.Length; i ++) document.write ('<caler name = nsMinutes' + i + 'top = 0 Left = 0 width = 15 height = 15> <font face = arial size = 3 color =' + mcol + '> <enter> <b>' + m [i] + '</b> </sender> </font> </yler>'); pour (i = 0; i <h.length; i ++) document.write ('<calern name = nshours' + i + 'top = 0 Left = 0 width = 15 height = 15> <font face = arial size = 3 color =' + hcol + '> <enter> <b>' + h [i] + '</b> </ centr> </font> </cheler>'); } if (ie) {document.write ('<div id = "od" style = "position: absolu; top: 0px; gauche: 0px"> <div style = "position: relative">'); pour (i = 0; i <d.Length; i ++) document.write ('<div id = "iedate" style = "position: absolu; top: 0px; gauche: 0; hauteur:' + a + '; width:' + a + '; text-align: Center">' + props2 + d [i] + '</b> </font> </v>'); document.write ('</div> </div>'); document.write ('<div id = "of" style = "position: absolu; top: 0px; gauche: 0px"> <div style = "position: relatif">'); pour (i = 0; i <n; i ++) document.write ('<div id = "ieface" style = "position: absolu; top: 0px; gauche: 0; hauteur:' + a + '; width:' + a + '; text-align: Center">' + props + face [i] + '</b> </font> </v>'); document.write ('</div> </div>'); document.write ('</div> </div>'); document.write ('<div id = "oh" style = "position: absolu; top: 0px; gauche: 0px"> <div style = "position: relatif">'); pour (i = 0; i <h.length; i ++) document.write ('<div id = "ieHours" style = "position: absolue; largeur: 16px; hauteur: 16px; font-family: arial; font-size: 16px: Color:' + hcol + '; Text-adign: Centre; font-weight: Bold">' + h [i] + '); document.write ('</div> </div>'); document.write ('<div id = "om" style = "position: absolu; top: 0px; gauche: 0px"> <div style = "position: relatif">'); pour (i = 0; i <M.Length; i ++) document.write ('<div id = "iemnutes" style = "position: absolu; largeur: 16px; hauteur: 16px; font-family: arial; font-size: 16px; colore:' + mcol + '; text-align: Center; font-weight: bold">' + m [i] + '; document.write ('</div> </div>') document.write ('<div id = "os" style = "position: absolu; top: 0px; gauche: 0px"> <div style = "position: relative">'); pour (i = 0; i <s.Length; i ++) document.write ('<div id = "ieseconds" style = "position: absolu; largeur: 16px; hauteur: 16px; font-family: arial; font-size: 16px; Color:' + scole + '; text-align: Center; font-weight: bold">' + s [i] + '; Document.Write ('</div> </div>')} (ns)? Window.CaptureEvents (event.mousmove): 0; fonction souris (evnt) {ymouse = (ns)? evnt.pagey + horlogefrommousey- (window.pageyoffset): event.y + horlogefrommousey; xmouse = (ns)? evnt.pagex + horlogefrommousex: event.x + horlogefrommousex; } (ns)? window.onmousmove = souris: document.onmousemove = souris; function horlogendassign () {time = new Date (); sec = time.getSeconds (); sec = -1,57 + math.pi * sec / 30; mins = time.getMinutes (); min = -1,57 + math.pi * min / 30; hr = time.Gethours (); hrs = -1,575 + math.pi * hr / 6 + math.pi * parseInt (time.getMinutes ()) / 360; if (ie) {od.style.top = window.document.body.scrolltop; De.style.top = window.document.body.scrolltop; Oh.style.top = window.document.body.scrolltop; Om.style.top = window.document.body.scrolltop; Os.style.top = window.document.body.scrolltop; } pour (i = 0; i <n; i ++) {var f = (ns)? document.layers ['nsface' + i]: ieface [i] .style; F.top = y [i] + Clockheight * Math.Sin (-1.0471 + i * Split * Math.pi / 180) + SCRLL; F.left = x [i] + ClockWidth * Math.cos (-1.0471 + i * Split * Math.pi / 180); } pour (i = 0; i <h.length; i ++) {var hl = (ns)? document.layers ['nShours' + i]: ieHours [i] .style; Hl.top = y [i] + Handy + (i * HandHeight) * math.sin (hrs) + scrll; Hl.left = x [i] + handx + (i * handwidth) * math.cos (hrs); } pour (i = 0; i <M.Length; i ++) {var ml = (ns)? Document.layers ['nsMinutes' + i]: iEMinutes [i] .Style; Ml.top = y [i] + Handy + (i * HandHeight) * Math.Sin (min) + scrll; Ml.left = x [i] + handx + (i * handwidth) * math.cos (min); } pour (i = 0; i <s.length; i ++) {var sl = (ns)? Document.layers ['nsseconds' + i]: ieseconds [i] .style; Sl.top = y [i] + Handy + (i * HandHeight) * Math.Sin (sec) + scrll; Sl.Left = x [i] + handx + (i * handwidth) * math.cos (sec); } pour (i = 0; i <d.Length; i ++) {var dl = (ns)? document.layers ['nsdate' + i]: iedate [i] .style; Dl.top = dy [i] + horlogehheight * 1.5 * math.sin (currstep + i * dsplit * math.pi / 180) + scll; Dl.left = dx [i] + ClockWidth * 1.5 * math.cos (currstep + i * dsplit * math.pi / 180); } currstep- = étape; } function delay () {scrll = (ns)? window.pageyoffset: 0; Dy [0] = math.round (dy [0] + = ((ymouse) -dy [0]) * Speed); Dx [0] = math.round (dx [0] + = ((xmouse) -dx [0]) * Speed); pour (i = 1; i <d.Length; i ++) {dy [i] = math.round (dy [i] + = (dy [i-1] -dy [i]) * vitesse); Dx [i] = math.round (dx [i] + = (dx [i-1] -dx [i]) * vitesse); } y [0] = math.round (y [0] + = ((ymouse) -y [0]) * Speed); x [0] = math.round (x [0] + = ((xmouse) -x [0]) * Speed); pour (i = 1; i <n; i ++) {y [i] = math.round (y [i] + = (y [i-1] -y [i]) * vitesse); x [i] = math.round (x [i] + = (x [i-1] -x [i]) * vitesse); } ClockandAssign (); setTimeout ('Delay ()', 40); } if (ns || ie) window.onload = retard; // -> </ script>