今天我学习到了一个用JavaScript制作的一个简单的网页日历时钟,它会在网页上显示今天的日期,和现在的时分秒。而且秒数还会在网页上面自动增加。
下面是效果图,没有进行界面美化加工的
下面分享源代码
<html>
<script>
// Insert before Body tag
<!--
function showGMTDateTime(){ // script by Peter Hawkespeterhawkes@btopenworld.com
if(document.getElementById){
if(document.getElementById) var obj = document.getElementById("showdate");
if(document.all) var obj = document.all("showdate");
var thedate = new Date();
obj.innerHTML =thedate.toGMTString().substring((thedate.toGMTString().length-4),0);
setTimeout('showGMTDateTime()',1000);}}
//-->
</script>
<style>
#showdate {
font-family:Verdana, Helvetica, Arial, sans-serif;
color:#000000;
font-size:12px;
}
</style>
//Insert in body Tag
<body οnlοad="showGMTDateTime()">
<p id="showdate"></p>
</body>
</html>