Phiên bản đầy đủ: jsB@nk » Thời gian » Đồng hồ » Hiển thị thời gian
URL: https://www.javascriptbank.com/dhtml-clock-script.html
Một đoạn mã JavaScript khác để tạo hiệu ứng hiển thị thời gian trên trang web bằng cách đơn giản.
Phiên bản đầy đủ: jsB@nk » Thời gian » Đồng hồ » Hiển thị thời gian
URL: https://www.javascriptbank.com/dhtml-clock-script.html
<script language="javascript">var ns4=(document.layers)?true:false;var ie4=(document.all && !document.getElementById)?true:false;var now=new Date();now.hrs='00';now.min='00';now.sec='00';var dclk;function setclock(){now=new Date(); now.hrs=now.getHours(); now.min=now.getMinutes(); now.sec=now.getSeconds();now.hrs=((now.hrs>12)? now.hrs-12 : now.hrs)+"";now.hrs=((now.hrs<10)? "0" : "")+now.hrs;now.min=((now.min<10)? "0" : "")+now.min;now.sec=((now.sec<10)? "0" : "")+now.sec;if(ns4){dclk.document.open();dclk.document.write('<div style="position:absolute; left:0px; top:0px; font-size:80px; color:white;"><center>'+now.hrs+':'+now.min+':'+now.sec+'</center></div>');dclk.document.close();}else dclk.innerHTML=now.hrs+':'+now.min+':'+now.sec;}window.onload=function(){ setInterval('setclock()',300); dclk=(ns4)?document.layers['dclk']:(ie4)?document.all['dclk']:document.getElementById('dclk');}window.onresize=function(){ if(ns4)setTimeout('history.go(0)',400);}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<table border="0" width="300" height="35"><tr><td align="center"><div id="dclk" style="position:relative; font-size:80px; color:#00436e;"></div></td></tr></table><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->