1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| <span onclick="afficher_horloge()">(icone horloge)</span>
<div id="div_horloge" style="display:none;"></div>
<script type="text/javascript">
function afficher_horloge()
{
var horloge = document.getElementById('div_horloge');
horloge.style.display = ( horloge.style.display == 'none' )? 'block':'none';
}
window.onload=function() {
horloge('div_horloge');
};
function horloge(el) {
if(typeof el=="string") { el = document.getElementById(el); }
function actualiser() {
var date = new Date();
var str = 'Nous sommes le '+date.getDate()+'/'+(date.getMonth()+1)+'/'+date.getFullYear()+'. Il est ';
str += date.getHours();
str += ':'+(date.getMinutes()<10?'0':'')+date.getMinutes();
str += ':'+(date.getSeconds()<10?'0':'')+date.getSeconds();
el.innerHTML = str;
}
actualiser();
setInterval(actualiser,1000);
}
</script> |
Partager