Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

AFFICHER L'HEURE DU NAVIGATEUR DANS LA BARE DE STATUS


Information sur la source

Description

Cliquez pour voir la capture en taille normale
Comment accéder à la bare de status du navigateur, en affichent son horaire actuel
 

Source

  • <html>
  • <Script LANGUAGE="JavaScript">
  • <!--
  • var timerID = null;
  • var TimerRunning = false;
  • function stop(){
  • if(TimerRunning)
  • clearTimeout(timerID);
  • TimerRunning = false;
  • }
  • function display() {
  • var thedate = new Date();
  • var hours = thedate.getHours();
  • var Min = thedate.getMinutes();
  • var Sec = thedate.getSeconds();
  • var TimeV = " il est exactement chez vous : " + hours
  • TimeV += ((Min < 10) ? ":0" : ":") + Min
  • TimeV += ((Sec < 10) ? ":0" : ":") + Sec
  • TimeV += (hours >= 12) ? " P.M." : " A.M."
  • window.status = TimeV;
  • timerID = setTimeout("display()",1000);
  • TimerRunning = true;
  • }
  • function start() {
  • stop();
  • display();
  • }
  • start();
  • // end hide -->
  • </Script>
  • <head>
  • <title> Titre de votre site </title>
  • <META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
  • </head>
  • <frameset rows="32,*,0" border=0>
  • <frame name="HEADER" src="header.html"
  • frameborder=0 marginheight=0 marginwidth=0 noresize scrolling="no">
  • <frame name="MAIN" src="Corps.htm"
  • frameborder=0 marginheight=0 marginwidth=0 noresize scrolling="auto">
  • <frame name="FOOTER" src="footer.html"
  • frameborder=0 marginheight=0 marginwidth=0 noresize scrolling="no">
  • </frameset>
  • </html>
<html>
<Script LANGUAGE="JavaScript">
<!--
var timerID = null;
var TimerRunning = false;

function stop(){
if(TimerRunning)
clearTimeout(timerID);
TimerRunning = false;
}

function display() {
var thedate = new Date();
var hours = thedate.getHours();
var Min = thedate.getMinutes();
var Sec = thedate.getSeconds();
var TimeV = " il est exactement chez vous : " +  hours
TimeV += ((Min < 10) ? ":0" : ":") + Min
TimeV += ((Sec < 10) ? ":0" : ":") + Sec
TimeV += (hours >= 12) ? " P.M." : " A.M."
window.status = TimeV;
timerID = setTimeout("display()",1000);
TimerRunning = true;
}

function start() {
stop();
display();
}

start();

// end hide -->
</Script>

<head>

     
<title> Titre de votre site </title>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8">
</head>
  
<frameset rows="32,*,0" border=0>

  <frame name="HEADER"   src="header.html"
   frameborder=0 marginheight=0 marginwidth=0 noresize scrolling="no">

  <frame name="MAIN"     src="Corps.htm"
   frameborder=0 marginheight=0 marginwidth=0 noresize scrolling="auto">

  <frame name="FOOTER"   src="footer.html"
   frameborder=0 marginheight=0 marginwidth=0 noresize scrolling="no">

</frameset>


</html>

Conclusion

On là met sur la page index du site
 

Commentaires et avis

signaler à un administrateur
Commentaire de roro06 le 15/01/2004 11:43:06

Equivalent, mais peut-etre plus simple :

var dayAr=new Date();
var deb="Heure d'arrivée : " + dayAr.getHours() + ":" + ((dayAr.getMinutes()&lt;=9)?"0":"") + dayAr.getMinutes() + ":"+ ((dayAr.getSeconds()&lt;=9)?"0":"") + dayAr.getSeconds();
decompteStatus();

function decompteStatus()
{
today=new Date();
var dif=(today - dayAr) / 1000;
window.status=deb + " et il est " + today.getHours() + ":" + ((today.getMinutes()&lt;=9)?"0":"") + today.getMinutes() + ":"+ ((today.getSeconds()&lt;=9)?"0":"") + today.getSeconds() + " temps passé : " + dif + " s.";
setTimeout("decompteStatus()", 1000);
}

signaler à un administrateur
Commentaire de cbeyls le 22/01/2005 01:58:31

Concernant le code original, il est bien, mais le start est mal fait. J'enlèverais le

TimerRunning = true;

de la fonction display() et j'écrirais le start() comme cela:

function start() {
   if(! TimerRunning) {
      TimerRunning = true;
      display();
   }
}

Ajouter un commentaire



Nos sponsors

Sondage...

CalendriCode

Janvier 2009
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Consulter la suite du CalendriCode



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel BAÏSE, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,328 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.