随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx

上传人:PIYPING 文档编号:11562741 上传时间:2021-08-24 格式:DOCX 页数:12 大小:13.96KB
返回 下载 相关 举报
随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx_第1页
第1页 / 共12页
随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx_第2页
第2页 / 共12页
随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx_第3页
第3页 / 共12页
随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx_第4页
第4页 / 共12页
随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx_第5页
第5页 / 共12页
亲,该文档总共12页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx》由会员分享,可在线阅读,更多相关《随鼠标移动的时钟特别美丽圆满的是只支持IE__1.docx(12页珍藏版)》请在三一文库上搜索。

1、随鼠标移动的时钟特别美丽圆满的是只支持IE_ 新建一个文本文件,将下面的代码复制进去,将文件名字改为clock.html运行即可。 view sourceprint?001 SCRIPT language=JavaScript!- 002 dCol=0000FF;/date colour. 003 fCol=0000FF;/face colour. 004 sCol=0000FF;/seconds colour. 005 mCol=0000FF;/minutes colour. 006 hCol=0000FF;/hours colour. 007 ClockHeight=40; 008 Clo

2、ckWidth=40; 009 ClockFromMouseY=0; 010 ClockFromMouseX=100; 011 /Alter nothing below! Alignments will be lost! 012 d=new Array(SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY); 013 m=new Array(JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER); 014 date=n

3、ew Date(); 015 day=date.getDate(); 016 year=date.getYear(); 017 if (year 2021) year=year+1900; 018 TodaysDate= +ddate.getDay()+ +day+ +mdate.getMonth()+ +year; 019 D=TodaysDate.split(); 020 H=.; 021 H=H.split(); 022 M=.; 023 M=M.split(); 024 S=.; 025 S=S.split(); 026 Face=1 2 3 4 5 6 7 8 9 10 11 12;

4、 027 font=Arial; 028 size=1; 029 speed=0.5; 030 ns=(document.layers); 031 ie=(document.all); 032 Face=Face.split( ); 033 n=Face.length; 034 a=size*10; 035 ymouse=0; 036 xmouse=0; 037 scrll=0; 038 props=font face=+font+ size=+size+ color=+fCol+B; 039 props2=font face=+font+ size=+size+ color=+dCol+B;

5、 040 Split=360/n; 041 Dsplit=360/D.length; 042 HandHeight=ClockHeight/4.5 043 HandWidth=ClockWidth/4.5 044 HandY=-7; 045 HandX=-2.5; 046 scrll=0; 047 step=0.06; 048 currStep=0; 049 y=new Array();x=new Array();Y=new Array();X=new Array(); 050 for (i=0; i n; i+)yi=0;xi=0;Yi=0;Xi=0 051 Dy=new Array();D

6、x=new Array();DY=new Array();DX=new Array(); 052 for (i=0; i D.length; i+)Dyi=0;Dxi=0;DYi=0;DXi=0 053 if (ns) 054 for (i=0; i D.length; i+) 055 document.write(layer name=nsDate+i+ top=0 left=0 height=+a+ width=+a+center+props2+Di+/font/center/layer); 056 for (i=0; i n; i+) 057 document.write(layer n

7、ame=nsFace+i+ top=0 left=0 height=+a+ width=+a+center+props+Facei+/font/center/layer); 058 for (i=0; i S.length; i+) 059 document.write(layer name=nsSeconds+i+ top=0 left=0 width=15 height=15font face=Arial size=3 color=+sCol+centerb+Si+/b/center/font/layer); 060 for (i=0; i M.length; i+) 061 docume

8、nt.write(layer name=nsMinutes+i+ top=0 left=0 width=15 height=15font face=Arial size=3 color=+mCol+centerb+Mi+/b/center/font/layer); 062 for (i=0; i H.length; i+) 063 document.write(layer name=nsHours+i+ top=0 left=0 width=15 height=15font face=Arial size=3 color=+hCol+centerb+Hi+/b/center/font/laye

9、r); 064 065 if (ie) 066 document.write(div id=Od style=position:absolute;top:0px;left:0pxdiv style=position:relative); 067 for (i=0; i D.length; i+) 068 document.write(div id=ieDate style=position:absolute;top:0px;left:0;height:+a+;width:+a+;text-align:center+props2+Di+/B/font/div); 069 document.wri

10、te(/div/div); 070 document.write(div id=Of style=position:absolute;top:0px;left:0pxdiv style=position:relative); 071 for (i=0; i n; i+) 072 document.write(div id=ieFace style=position:absolute;top:0px;left:0;height:+a+;width:+a+;text-align:center+props+Facei+/B/font/div); 073 document.write(/div/div

11、); 074 document.write(div id=Oh style=position:absolute;top:0px;left:0pxdiv style=position:relative); 075 for (i=0; i H.length; i+) 076 document.write(div id=ieHours style=position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:+hCol+;text-align:center;font-weight:bold+Hi+/di

12、v); 077 document.write(/div/div); 078 document.write(div id=Om style=position:absolute;top:0px;left:0pxdiv style=position:relative); 079 for (i=0; i M.length; i+) 080 document.write(div id=ieMinutes style=position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:+mCol+;text-ali

13、gn:center;font-weight:bold+Mi+/div); 081 document.write(/div/div) 082 document.write(div id=Os style=position:absolute;top:0px;left:0pxdiv style=position:relative); 083 for (i=0; i S.length; i+) 084 document.write(div id=ieSeconds style=position:absolute;width:16px;height:16px;font-family:Arial;font

14、-size:16px;color:+sCol+;text-align:center;font-weight:bold+Si+/div); 085 document.write(/div/div) 086 087 (ns)?window.captureEvents(Event.MOUSEMOVE):0; 088 function Mouse(evnt) 089 ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY; 090 xmouse = (ns)?evnt.pageX+Clo

15、ckFromMouseX:event.x+ClockFromMouseX; 091 092 (ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse; 093 function ClockAndAssign() 094 time = new Date (); 095 secs = time.getSeconds(); 096 sec = -1.57 + Math.PI * secs/30; 097 mins = time.getMinutes(); 098 min = -1.57 + Math.PI * mins/30; 099 hr =

16、 time.getHours(); 100 hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes()/360; 101 if (ie) 102 Od.style.top=window.document.body.scrollTop; 103 Of.style.top=window.document.body.scrollTop; 104 Oh.style.top=window.document.body.scrollTop; 105 Om.style.top=window.document.body.scrollTop;

17、106 Os.style.top=window.document.body.scrollTop; 107 108 for (i=0; i n; i+) 109 var F=(ns)?document.layersnsFace+i:ieFacei.style; 110 F.top=yi + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll; 111 F.left=xi + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180); 112 113 for (i=0; i H.length

18、; i+) 114 var HL=(ns)?document.layersnsHours+i:ieHoursi.style; 115 HL.top=yi+HandY+(i*HandHeight)*Math.sin(hrs)+scrll; 116 HL.left=xi+HandX+(i*HandWidth)*Math.cos(hrs); 117 118 for (i=0; i M.length; i+) 119 var ML=(ns)?document.layersnsMinutes+i:ieMinutesi.style; 120 ML.top=yi+HandY+(i*HandHeight)*M

19、ath.sin(min)+scrll; 121 ML.left=xi+HandX+(i*HandWidth)*Math.cos(min); 122 123 for (i=0; i S.length; i+) 124 var SL=(ns)?document.layersnsSeconds+i:ieSecondsi.style; 125 SL.top=yi+HandY+(i*HandHeight)*Math.sin(sec)+scrll; 126 SL.left=xi+HandX+(i*HandWidth)*Math.cos(sec); 127 128 for (i=0; i D.length;

20、 i+) 129 var DL=(ns)?document.layersnsDate+i:ieDatei.style; 130 DL.top=Dyi + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll; 131 DL.left=Dxi + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180); 132 133 currStep-=step; 134 135 function Delay() 136 scrll=(ns)?window.pageYOffset:0;

21、137 Dy0=Math.round(DY0+=(ymouse)-DY0)*speed); 138 Dx0=Math.round(DX0+=(xmouse)-DX0)*speed); 139 for (i=1; i D.length; i+) 140 Dyi=Math.round(DYi+=(Dyi-1-DYi)*speed); 141 Dxi=Math.round(DXi+=(Dxi-1-DXi)*speed); 142 143 y0=Math.round(Y0+=(ymouse)-Y0)*speed); 144 x0=Math.round(X0+=(xmouse)-X0)*speed); 145 for (i=1; i n; i+) 146 yi=Math.round(Yi+=(yi-1-Yi)*speed); 147 xi=Math.round(Xi+=(xi-1-Xi)*speed); 148 149 ClockAndAssign(); 150 setTimeout(Delay(),40); 151 152 if (ns|ie)window.onload=Delay; 153 / -/SCRIPT 更多信息请查看IT技术专栏 .

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1