Mostrar relógio na barra de status do browser

2010-05-07 22:06

Com este código é possível inserir de forma simples um relógio na barra de status do navegador.

Este recurso pode ser interessante para sites que precisem informar a todo momento a hora. 

OBS: A hora apresentada é a que está configurada no computador do usuário (cliente). Este script é compatível apenas com o Internet Explorer 

 

 

 

<html>

 

<head>

<title>Relógio na Barra de Status</title>

<script Language="JavaScript">

<!-- 

var timerID = null;

var timerRunning = false;

function stopclock (){

        if(timerRunning)

                clearTimeout(timerID);

        timerRunning = false;

}

 

function showtime() {

        var now = new Date();

        var hours = now.getHours();

        var minutes = now.getMinutes();

        var seconds = now.getSeconds()

        var timeValue = "" + ((hours >12) ? hours -12 :hours)

        timeValue += ((minutes < 10) ? ":0" : ":") + minutes

        timeValue += ((seconds < 10) ? ":0" : ":") + seconds

        timeValue += (hours >= 12) ? " PM" : " AM"

 

        //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;

}

 

function startclock () {

        // Make sure the clock is stopped

        stopclock();

        showtime();

}

 

-->

</script>

</head>

 

<body TEXT="#000000" BGCOLOR="#ffffff" LINK="#000000" VLINK="#000000" ALINK="#000000"

ONLOAD="startclock()">

 

<dl>

  <div align="center"><center>

  <dt><font SIZE="+2" COLOR="#000000"><b>Relógio na barra de Status</b></font><br>

    <br>

    <br>

    <br>

    <br>

    <br>

    <br>

    <br>

  </dt>

  </center></div>

</dl>

</body>

</html>


Related Posts with Thumbnails