Probleme affichage horloge

Résolu/Fermé
hyoga40 Messages postés 9 Date d'inscription mercredi 1 juin 2016 Statut Membre Dernière intervention 13 février 2023 - Modifié par jordane45 le 27/01/2017 à 11:55
hyoga40 Messages postés 9 Date d'inscription mercredi 1 juin 2016 Statut Membre Dernière intervention 13 février 2023 - 29 janv. 2017 à 10:31
Bonjour,

Je laisse ce message car j'ai un soucis avec mon horloge. En effet l'heure n'apparait plus pouvez vous m'aider à trouver la raison du problème merci d'avance ?
Voici le code que j'utilise :

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title>Horloge</title> 
<SCRIPT LANGUAGE="JavaScript"> 
navvers = navigator.appVersion.substring(0,1); 
if (navvers > 3) 
 navok = true; 
else 
 navok = false; 

today = new Date; 
numero = today.getDate(); 
if (numero<10) 
 numero = "0"+numero; 
mois = today.getMonth(); 
if (navok) 
 annee = today.getFullYear(); 
else 
 annee = today.getYear(); 
mois++; 
if (mois < 10) 
 mois = "0" + mois; 
messageDate = numero + "/" + mois + "/" + annee; 
function HeureCheck() 
{ 
krucial = new Date; 
heure = krucial.getHours(); 
min = krucial.getMinutes(); 
sec = krucial.getSeconds(); 
jour = krucial.getDate(); 
mois = krucial.getMonth()+1; 
annee = krucial.getFullYear(); 
if (sec < 10) 
sec0 = "0"; 
else 
sec0 = ""; 
if (min < 10) 
min0 = "0"; 
else 
min0 = ""; 
if (heure < 10) 
heure0 = "0"; 
else 
heure0 = ""; 
DinaHeure = heure0 + heure + ":" + min0 + min + ":" + sec0 + sec; 
which = DinaHeure 
if (document.all){ 
dynamic3.innerHTML='<center>00:00:00</center>' 
dynamic3.innerHTML='<FONT SIZE=2 FACE=" comic sans ms black "><B>'+which+'</B></FONT>'; 
} 
else if (document.layers){ 
document.dynamic1.document.dynamic2.document.write(''+which+'') 
document.dynamic1.document.dynamic2.document.close() 
} 
tempo = setTimeout("HeureCheck()", 1000) 
} 
</SCRIPT> 
</head> 
<body onLoad="HeureCheck()" onUnload="clearTimeout(tempo)"> 


<table border="0" cellspacing="0" cellpadding="0" width="50" height="50"> 
  <tr> 
<td bgcolor="#000000" style="border: 1 solid #000000 " > 
<table summary="" border="0" width="100%" height="100%"> 
<tr> 
<!--  couleur fond et texte --> 
<td  background="#000000"><CENTER> 
<font color="#FFFFFF"> 
<!--  fin couleur fond et texte --> 
<FONT SIZE=2 FACE="comic sans ms black"><B><SCRIPT LANGUAGE="JavaScript"> document.write(messageDate); </SCRIPT> 
              </B></FONT>  
              <!-- image ici  --> 
              <a title="Cartoons spirit" href="http://www.cartoons-spirit.fr/" rel="nofollow noopener noreferrer" target="_blank">  
              <img border="0" src=""quot;"quot;http://cartoons.spirit.free.fr/Monsite/Horloge/HORLOGE1.jpg" width="135" height="170"></a> 
              <!-- fin image ici --> 
              </a>  
              <ilayer id="dynamic1" width=100% height=15><layer id="dynamic2" width=100% height=15><div id="dynamic3"></div></layer></ilayer> 
        </font></CENTER> 
  </td> 
 </tr> 
</table> 
 </tr> 
</table> 
</body> 
</html>

EDIT : Ajout des balises de code

Explications ici : https://codes-sources.commentcamarche.net/faq/10686-le-nouveau-codes-sources-comment-ca-marche#balises-code
A voir également:

2 réponses

jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 4 650
Modifié par jordane45 le 27/01/2017 à 12:13
Bonjour;

Ceci devrait fonctionner:
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<title>Horloge</title> 
<SCRIPT type="text/javascript"> 
var tempo;
function get_date(){
  navok = navigator.appVersion.substring(0,1) > 3 ? true : false ;

  today = new Date; 
  numero = today.getDate(); 
  numero = numero < 10 ? "0"+numero : numero; 

  annee = navok ? today.getFullYear() : today.getYear(); 

  mois = today.getMonth() + 1 < 10 ? "0" + (today.getMonth() + 1) :(today.getMonth() + 1) ; 
  messageDate = numero + "/" + mois + "/" + annee; 
  return messageDate;
}


function HeureCheck() { 
  krucial = new Date; 
  heure = krucial.getHours(); 
  min = krucial.getMinutes(); 
  sec = krucial.getSeconds(); 
  jour = krucial.getDate(); 
  mois = krucial.getMonth()+1; 
  annee = krucial.getFullYear(); 

  sec0 = sec < 10 ? "0" : "";
  min0 = min < 10 ? "0" : "";
  heure0 = heure < 10 ? "0" : "";

  which = heure0 + heure + ":" + min0 + min + ":" + sec0 + sec; 

  document.getElementById('dynamic3').innerHTML='<FONT SIZE=2 FACE=" comic sans ms black "><B>'+which+'</B></FONT>'; 

  tempo = setTimeout("HeureCheck()", 1000);
} 
</SCRIPT> 
</head> 
<body onLoad="HeureCheck()" onUnload="clearTimeout(tempo)"> 


<table border="0" cellspacing="0" cellpadding="0" width="50" height="50"> 
  <tr> 
<td bgcolor="#000000" style="border: 1 solid #000000 " > 
<table summary="" border="0" width="100%" height="100%"> 
<tr> 
<!--  couleur fond et texte --> 
<td  background="#000000"><CENTER> 
<font color="#FFFFFF"> 
<!--  fin couleur fond et texte --> 
<FONT SIZE=2 FACE="comic sans ms black"><B><SCRIPT LANGUAGE="JavaScript"> document.write(get_date()); </SCRIPT> 
              </B></FONT> 
 <!-- image ici  --> 
              <a title="Cartoons spirit" href="http://www.cartoons-spirit.fr/" rel="nofollow noopener noreferrer" target="_blank">  
              <img border="0" src=""apos;http://cartoons.spirit.free.fr/Monsite/Horloge/HORLOGE1.jpg' width="135" height="170"></a> 
              <!-- fin image ici --> 
              </a>   
              <ilayer id="dynamic1" width=100% height=15><layer id="dynamic2" width=100% height=15><div id="dynamic3"></div></layer></ilayer> 
        </font></CENTER> 
  </td> 
 </tr> 
</table> 
 </tr> 
</table> 
</body> 
</html>

Cordialement, 
Jordane                                                                 
0
hyoga40 Messages postés 9 Date d'inscription mercredi 1 juin 2016 Statut Membre Dernière intervention 13 février 2023
29 janv. 2017 à 10:31
Merci Jordane pour ton aide mon horloge marche maintenant très bien.
N'étant pas un pro du codage informatique j'étais un peu perdu. J'ai un vieux site qui malgré son age à pas mal de visite et j'essaie de le garder compatible avec tous les navigateurs et l'horloge était l'un de mes problèmes avec les paragraphes de textes qui sont trop long sur Chrome et Android (Edge et internet explorer impeccable).
Merci encore pour ton aide et passe un bon week end.
0