一个用JavaScript写的简单时钟
1) 写这个时钟需要获取当前的windows时间,可用time = new Date ()来实现,
获取小时为: Hour = now.getHours();
分钟数为: Minute = now.getMinutes();
秒数为: Second = now.getSeconds();
2)如何描点作图?使用<div>标签可以实现,设置position为absolute即能确定位置坐标,横坐标为Left,纵坐标为Top。
例如代码中 <div id=”c1″ style=”position:absolute;left:20;top:-20; z-index:5;font-size:11px;”><b>1</b></div>
就是十二个点中其中中一点的表达方式。
3)绘制一个圆。圆心坐标为pX=400;pY=200分别为纵坐标与横坐标。然后在函数 timer(),利用三角函数作圆。
代码可以在浏览器中的“查看”–>“源文件”中获取。
您可能会喜欢:
Filed under 原创javascript, 网站相关. Tags: JavaScript
在firefox下没有看到效果,有页面源代码,但是没有看到效果
[回复]
@fly3q
各种浏览器都会有不同的效果,搞的有点晕 :roll:
[回复]
Super text, I will add this blog to my favorites.
[回复]
It looks like after last nights draft my fantasy football team is going to kick some butt! :)
[回复]
wtwzjbyp
[回复]