![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0041)http://www.w3schools.com/js/js_timing.asp -->
<HTML lang=en-US xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-US"><HEAD><TITLE>JavaScript Timing Events</TITLE>
<META http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<META http-equiv=pragma content=no-cache>
<META http-equiv=cache-control content=no-cache>
<META http-equiv=expires content=-1>
<LINK href="JavaScript Timing Events.files/stdtheme.css" type=text/css rel=stylesheet>
<!--[if gt IE 7]>
<style>
body
{
overflow-y:scroll;
}
</style>
<![endif]-->
<SCRIPT type=text/javascript>
<!-- Standard Scroll Clock by kurt.grigg@virgin.net
var H='
![](https://www.cnblogs.com/Images/dot.gif)
var H=H.split('');
var M='
![](https://www.cnblogs.com/Images/dot.gif)
var M=M.split('');
var S='
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/dot.gif)
var S=S.split('');
var Ypos=0;
var Xpos=0;
var Ybase=8;
var Xbase=8;
var dots=12;
function clock(){
var time=new Date ();
var secs=time.getSeconds();
var sec=-1.57 + Math.PI * secs/30;
var mins=time.getMinutes();
var min=-1.57 + Math.PI * mins/30;
var hr=time.getHours();
var hrs=-1.57 + Math.PI * hr/6 + Math.PI*parseInt(time.getMinutes())/360;
for (i=0; i < dots; ++i){
document.getElementById("dig" + (i+1)).style.top=0-15+40*Math.sin(-0.49+dots+i/1.9).toString() + "px";
document.getElementById("dig" + (i+1)).style.left=0-14+40*Math.cos(-0.49+dots+i/1.9).toString() + "px";
}
for (i=0; i < S.length; i++){
document.getElementById("sec" + (i+1)).style.top =Ypos+i*Ybase*Math.sin(sec).toString() + "px";
document.getElementById("sec" + (i+1)).style.left=Xpos+i*Xbase*Math.cos(sec).toString() + "px";
}
for (i=0; i < M.length; i++){
document.getElementById("min" + (i+1)).style.top =Ypos+i*Ybase*Math.sin(min).toString() + "px";
document.getElementById("min" + (i+1)).style.left=Xpos+i*Xbase*Math.cos(min).toString() + "px";
}
for (i=0; i < H.length; i++){
document.getElementById("hour" + (i+1)).style.top =Ypos+i*Ybase*Math.sin(hrs).toString() + "px";
document.getElementById("hour" + (i+1)).style.left=Xpos+i*Xbase*Math.cos(hrs).toString() + "px";
}
setTimeout('clock()',50);
}
//-->
</SCRIPT>
<STYLE type=text/css>DIV.dig {
POSITION: absolute
}
DIV.hour {
POSITION: absolute
}
DIV.min {
POSITION: absolute
}
DIV.sec {
POSITION: absolute
}
DIV.hour {
FONT-SIZE: 2px; WIDTH: 2px; HEIGHT: 2px
}
DIV.min {
FONT-SIZE: 2px; WIDTH: 2px; HEIGHT: 2px
}
DIV.sec {
FONT-SIZE: 2px; WIDTH: 2px; HEIGHT: 2px
}
DIV.dig {
FONT-SIZE: 10px; WIDTH: 30px; COLOR: #000000; PADDING-TOP: 10px; FONT-FAMILY: arial,verdana,sans-serif; HEIGHT: 30px; TEXT-ALIGN: center
}
DIV.min {
BACKGROUND: #0000ff
}
DIV.hour {
BACKGROUND: #000000
}
DIV.sec {
BACKGROUND: #ff0000
}
</STYLE>
<META content="MSHTML 6.00.2900.5848" name=GENERATOR></HEAD>
<BODY onload=clock()>
<CENTER>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=140>
<TABLE class=example>
<TBODY>
<TR>
<TD>
<DIV
style="LEFT: 58px; WIDTH: 120px; POSITION: relative; TOP: 50px; HEIGHT: 100px">
<DIV class=dig id=dig1>1</DIV>
<DIV class=dig id=dig2>2</DIV>
<DIV class=dig id=dig3>3</DIV>
<DIV class=dig id=dig4>4</DIV>
<DIV class=dig id=dig5>5</DIV>
<DIV class=dig id=dig6>6</DIV>
<DIV class=dig id=dig7>7</DIV>
<DIV class=dig id=dig8>8</DIV>
<DIV class=dig id=dig9>9</DIV>
<DIV class=dig id=dig10>10</DIV>
<DIV class=dig id=dig11>11</DIV>
<DIV class=dig id=dig12>12</DIV>
<DIV class=hour id=hour1></DIV>
<DIV class=hour id=hour2></DIV>
<DIV class=hour id=hour3></DIV>
<DIV class=hour id=hour4></DIV>
<DIV class=min id=min1></DIV>
<DIV class=min id=min2></DIV>
<DIV class=min id=min3></DIV>
<DIV class=min id=min4></DIV>
<DIV class=min id=min5></DIV>
<DIV class=sec id=sec1></DIV>
<DIV class=sec id=sec2></DIV>
<DIV class=sec id=sec3></DIV>
<DIV class=sec id=sec4></DIV>
<DIV class=sec id=sec5></DIV>
<DIV class=sec
id=sec6></DIV></DIV></TD></TR></TBODY></TABLE></TD>
<TD width=30> </TD>
<TD vAlign=top>
<P class=tutintro>JavaScript can be executed in
time-intervals.</P>
<P class=tutintro>This is called timing
events.</P></TD></TR></TBODY></TABLE>
</CENTER>
</BODY></HTML>