日期:2014-05-16  浏览次数:20422 次

超赞javascript 钟表
不知道是哪位高人写的,纯javascript写的钟表,时针,分针,秒针都有,年月日,星期也在内。效果图:

<SCRIPT language=JavaScript> 
dCol='000000';//date colour.
fCol='000000';//face colour.
sCol='red';//seconds colour.
mCol='000000';//minutes colour.
hCol='000000';//hours colour.
ClockHeight=40;
ClockWidth=40;
ClockFromMouseY=0;
ClockFromMouseX=100;
 
d=new Array(&quot;SUNDAY&quot;,&quot;MONDAY&quot;,&quot;TUESDAY&quot;,&quot;WEDNESDAY&quot;,&quot;THURSDAY&quot;,&quot;FRIDAY&quot;,&quot;SATURDAY&quot;);
m=new Array(&quot;JANUARY&quot;,&quot;FEBRUARY&quot;,&quot;MARCH&quot;,&quot;APRIL&quot;,&quot;MAY&quot;,&quot;JUNE&quot;,&quot;JULY&quot;,&quot;AUGUST&quot;,&quot;SEPTEMBER&quot;,&quot;OCTOBER&quot;,&quot;NOVEMBER&quot;,&quot;DECEMBER&quot;);
date=new Date();
day=date.getDate();
year=date.getYear();
if (year &lt; 2000) year=year+1900;
TodaysDate=&quot; &quot;+d[date.getDay()]+&quot; &quot;+day+&quot; &quot;+m[date.getMonth()]+&quot; &quot;+year;
D=TodaysDate.split('');
H='...';
H=H.split('');
M='....';
M=M.split('');
S='.....';
S=S.split('');
Face='1 2 3 4 5 6 7 8 9 10 11 12';
font='Arial';
size=1;
speed=0.6;
ns=(document.layers);
ie=(document.all);
Face=Face.split(' ');
n=Face.length;
a=size*10;
ymouse=0;
xmouse=0;
scrll=0;
props=&quot;&lt;font face=&quot;+font+&quot; size=&quot;+size+&quot; color=&quot;+fCol+&quot;&gt;&lt;B&gt;&quot;;
props2=&quot;&lt;font face=&quot;+font+&quot; size=&quot;+size+&quot; color=&quot;+dCol+&quot;&gt;&lt;B&gt;&quot;;
Split=360/n;
Dsplit=360/D.length;
HandHeight=ClockHeight/4.5
HandWidth=ClockWidth/4.5
HandY=-7;
HandX=-2.5;
scrll=0;
step=0.06;
currStep=0;
y=new Array();x=new Array();Y=new Array();X=new Array();
for (i=0; i &lt; n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0}
Dy=new Array();Dx=new Array();DY=new Array();DX=new Array();
for (i=0; i &lt; D.length; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0}
if (ns){
for (i=0; i &lt; D.length; i++)
document.write('&lt;layer name=&quot;nsDate'+i+'&quot; top=0 left=0 height='+a+' width='+a+'&gt;&lt;center&gt;'+props2+D[i]+'&lt;/font&gt;&lt;/center&gt;&lt;/layer&gt;');
for (i=0; i &lt; n; i++)
document.write('&lt;layer name=&quot;nsFace'+i+'&quot; top=0 left=0 height='+a+' width='+a+'&gt;&lt;center&gt;'+props+Face[i]+'&lt;/font&gt;&lt;/center&gt;&lt;/layer&gt;');
for (i=0; i &lt; S.length; i++)
document.write('&lt;layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15&gt;&lt;font face=Arial size=3 color='+sCol+'&gt;&lt;center&gt;&lt;b&gt;'+S[i]+'&lt;/b&gt;&lt;/center&gt;&lt;/font&gt;&lt;/layer&gt;');
for (i=0; i &lt; M.length; i++)
document.write('&lt;layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15&gt;&lt;font face=Arial size=3 color='+mCol+'&gt;&lt;center&gt;&lt;b&gt;'+M[i]+'&lt;/b&gt;&lt;/center&gt;&lt;/font&gt;&lt;/layer&gt;');
for (i=0; i &lt; H.length; i++)
document.write('&lt;layer name=nsHours'+i+' top=0 left=0 width=15 height=15&gt;&lt;font face=Arial size=3 color='+hCol+'&gt;&lt;center&gt;&lt;b&gt;'+H[i]+'&lt;/b&gt;&lt;/center&gt;&lt;/font&gt;&lt;/layer&gt;');
}
if (ie){
document.write('&lt;div id=&quot;Od&quot; style=&quot;position:absolute;top:0px;left:0px&quot;&gt;&lt;div style=&quot;position:relative&quot;&gt;');
for (i=0; i &lt; D.length; i++)
document.write('&lt;div id=&quot;ieDate&quot; style=&quot;position