当前位置:K88软件开发文章中心电脑基础基础应用13 → 文章内容

JavaScript教程之网页时钟

减小字体 增大字体 作者:华军  来源:华军资讯  发布时间:2019-2-1 22:54:34

te;);《BR》document.write(´《/div》《/div》´);《BR》document.write(´《div id=“Of” style=“position:absolute;top:0px;left:0px”》《div style=“position:relative”》´);《BR》for (i=0; i 《 n; i++)《BR》document.write(´《div id=“ieFace” style=“position:absolute;top:0px;left:0;height:´+a+´;width:´+a+´;text-align:center”》´+props+Face[i]+´《/font》《/div》´);《BR》document.write(´《/div》《/div》´);《BR》document.write(´《div id=“Oh” style=“position:absolute;top:0px;left:0px”》《div style=“position:relative”》´);《BR》for (i=0; i 《 H.length; i++)《BR》document.write(´《div id=“ieHours” style=“position:absolute;width:16px;《BR》height:16px;font-family:Arial;font-size:16px;color:´+hCol+´;text-align:center;font-weight:bold”》´+H[i]+´《/div》´);《BR》document.write(´《/div》《/div》´);《BR》document.write(´《div id=“Om” style=“position:absolute;top:0px;left:0px”》《div style=“position:relative”》´);《BR》for (i=0; i 《 M.length; i++)《BR》document.write(´《div id=“ieMinutes” style=“position:absolute;width:16px;《BR》height:16px;font-family:Arial;font-size:16px;color:´+mCol+´;text-align:center;font-weight:bold”》´+M[i]+´《/div》´);《BR》document.write(´《/div》《/div》´)《BR》document.write(´《div id=“Os” style=“position:absolute;top:0px;left:0px”》《div style=“position:relative”》´);《BR》for (i=0; i 《 S.length; i++)《BR》document.write(´《div id=“ieSeconds” style=“position:absolute;width:16px;《BR》height:16px;font-family:Arial;font-size:16px;color:´+sCol+´;text-align:center;font-weight:bold”》´+S[i]+´《/div》´);《BR》document.write(´《/div》《/div》´)《BR》}《BR》(ns)?window.captureEvents(Event.MOUSEMOVE):0;《BR》function Mouse(evnt){《BR》ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):《BR》event.y+ClockFromMouseY;《BR》xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;《BR》}《BR》(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;《BR》function ClockAndAssign(){《BR》time = new Date ();《BR》secs = time.getSeconds();《BR》sec = -1.57 + Math.PI * secs/30;《BR》mins = time.getMinutes();《BR》min = -1.57 + Math.PI * mins/30;《BR》hr = time.getHours();《BR》hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;《BR》if (ie){《BR》Od.style.top=window.document.body.scrollTop;《BR》Of.style.top=window.document.body.scrollTop;《BR》Oh.style.top=window.document.body.scrollTop;《BR》Om.style.top=window.document.body.scrollTop;《BR》Os.style.top=window.document.body.scrollTop;《BR》}《BR》for (i=0; i 《 n; i++){《BR》var F=(ns)?document.layers[´nsFace´+i]:ieFace[i].style;《BR》F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll;《BR》F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180);《BR》}《BR》for (i=0; i 《 H.length; i++){《BR》var HL=(ns)?document.layers[´nsHours´+i]:ieHours[i].style;《BR》HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;《BR》HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs);《BR》}《BR》for (i=0; i 《 M.length; i++){《BR》var ML=(ns)?document.layers[´nsMinutes´+i]:ieMinutes[i].style;《BR》ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;《BR》ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min);《BR》}《BR》for (i=0; i 《 S.length; i++){《BR》var SL=(ns)?document.layers[´nsSeconds´+i]:ieSeconds[i].style;《BR》SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll;《BR》SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec);《BR》}《BR》for (i=0; i 《 D.length; i++){《BR》var DL=(ns)?document.layers[´nsDate´+i]:ieDate[i].style;《BR》DL.top=Dy[i] + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll;《BR》DL.left=Dx[i] + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180);《BR》}《BR》currStep-=step;《BR》}《BR》function Delay(){《BR》scrll=(ns)?window.pageYOffset:0;《BR》Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed);《BR》Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed);《BR》for (i=1; i 《 D.length; i++){《BR》Dy[i]=Math.round(DY[i]+=(Dy[i-1]-DY[i])*speed);《BR》Dx[i]=Math.round(DX[i]+=(Dx[i-1]-DX[i])*speed);《BR》}《BR》y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);《BR》x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);《BR》for (i=1; i 《 n; i++){《BR》y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);《BR》x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);《BR》}《BR》ClockAndAssign();《BR》setTimeout(´Delay()´,20);《BR》}《BR》if (ns||ie)window.onload=Delay;《BR》//--》《BR》《/SCRIPT》

上一页  [1] [2] 


JavaScript教程之网页时钟