标题:自己做了个背景时钟
取消只看楼主
ckdown
Rank: 1
来 自:青海海西州蒙古大草原
等 级:新手上路
帖 子:9
专家分:0
注 册:2009-10-28
结帖率:33.33%
 问题点数:0 回复次数:0 
自己做了个背景时钟
<html>
<head>
<title>背景时钟</title>
<script type="text/javascript">
<!--//
function clockon(){
thistime = new Date()
//获取小时
var hours = thistime.getHours();
//获取分钟
var minutes = thistime.getMinutes();
//获取秒
var seconds = thistime.getSeconds();
//为个位数的时间前面加0
if(eval(hours) < 10)
{
hours = "0" + hours;
}
if(eval(minutes) < 10)
{
minutes = "0" + minutes;
}
if(seconds < 10)
{
seconds = "0" + seconds;
}
thistime = hours + ":" + minutes + ":" +seconds;
if(document.all){
bgclocknoshade.innerHTML = thistime;
bgclockshade.innerTHML = thistime;
}
//document.layers Netscape 4.x专有属性
if(document.layers){
document.bgclockshade.document.write('<div id="bgclockshade" style="position:absolute; visibility:visible; font-family:Verdana; color:ffaaaa; font-size:120px; top:10px; left:152px">'+thistime+'</div>');
document.bgclocknoshade.document.write('<div id="bgclocknoshade" style="position:absolute; visibility:visible; font-family:Verdana; color:dddddd; font-size:120px; top:10px; left:150px">'+thistime+'</div>');
document.close();
}
var timer = setTimeout("clockon()",200);
}
//-->
</script>
</head>
<body onLoad="clockon()">
<div id="bgclockshade" style="position:absolute; visibility:visible; font-family:Verdana; color:ffaaaa; font-size:120px; top:10px; left:152px"></div>
<div id="bgclocknoshade" style="position:absolute; visibility:visible; font-family:Verdana; color:dddddd; font-size:120px; top:10px; left:150px"></div>
<div id="mainbody" style="position:absolute; visibility:visible;"></div>
</body>
</html>

时钟显示的位置需要通过修正top和left参数来确定。top表示层距离显示器顶部的像素值,left表示距离左侧的像素值。
搜索更多相关主题的帖子: 时钟 function minutes seconds 
2013-02-26 16:58



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-399223-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.551277 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved