您的位置:首页 > Web前端 > JavaScript

JavaScript小特效---简单的网页日历时钟

2017-01-03 17:10 543 查看
今天我学习到了一个用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 onload="showGMTDateTime()">
<p id="showdate"></p>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: