新しいテキストファイルを作成し、次のコードをコピーし、ファイル名をclock.htmlに変更して実行します。
<スクリプト言語= javascript> <! - dcol = '0000ff'; //日付色。 fcol = '0000ff'; //顔の色。 scol = '0000ff'; //秒の色。 mcol = '0000ff'; //分。 hcol = '0000ff'; //時間の色。 clockheight = 40; clockWidth = 40; clockfrommousey = 0; clockfrommousex = 100; //以下で何も変更しません!アラインメントは失われます! d = new Array( "Sunday"、 "Monday"、 "火曜日"、「水曜日」、「木曜日」、「金曜日」、「土曜日」); m = new Array( "1月"、「2月」、「3月」、「4月」、「5月」、「6月」、「7月」、「8月」、「9月」、「10月」、「11月」、「12月」); date = new date(); day = date.getDate(); year = date.getyear(); if(year <2000)year = year+1900; todaysdate = ""+d [date.getDay()]+""+day+""+m [date.getMonth()]+""+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';サイズ= 1;速度= 0.5; ns =(document.layers); ie =(document.all); face = face.split( ''); n = face.length; a = size*10; ymouse = 0; xmouse = 0; scrll = 0; props = "<font face ="+font+"size ="+size+"color ="+fcol+"> <b>"; props2 = "<font face ="+font+"size ="+size+"color ="+dcol+"> <b>";分割= 360/n; dsplit = 360/d.length; Handheight = clockheight/4.5 Handwidth = clockWidth/4.5 Handy = -7; handx = -2.5; scrll = 0;ステップ= 0.06; CurrStep = 0; y = new array(); x = new array(); y = new array(); x = new array(); for(i = 0; i <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 <d.length; i ++){dy [i] = 0; dx [i] = 0; dy [i] = 0; dx [i] = 0} if(ns){for(i = 0; i <d.length; i ++)document.write( '<レイヤーname = "nsdate'+i+'+0 = 0+0 width = '+a+'> <center> '+props2+d [i]+' </font> </center> </layer> '); for(i = 0; i <n; i ++)document.write( '<layer name = "nsface'+i+'" top = 0 left = 0 height = 0 height ='+a+'width ='+a+'> <center>'+face [i]+'</font> </center> </レイヤー>'); for(i = 0; i <s.length; i ++)document.write( '<layer name = nsseconds'+i+'top = 0左= 0 width = 15> <font face = 3 color ='+scol+'> <center> <b>'+s [i]+'</b> for(i = 0; i <m.length; i ++)document.write( '<layer name = nsminutes'+i+'top = 0左= 0 width = 15> <font face = 3 color ='+'> <center> <b>'+m [i]+'</b> for(i = 0; i <h.length; i ++)document.write( '<layer name = nshours'+i+'top = 0左= 0 width = 15> <font face = 3 color ='+hcol+'> <center> <b>'+h [i]+'</b> } if(ie){document.write( '<div id = "od" style = "position:absolute; top:0px; left:0px"> <div style = "position:relative">'); for(i = 0; i <d.length; i ++)document.write( '<div id = "iedate" style = "position:absolute; top:0px; left:0; height:'+a+'; width:'+a+'; text-align:center">'+props2+d [i]+'</b> </font> </div>'); document.write( '</div> </div>'); document.write( '<div id = "of" style = "position:absolute; top:0px; left:0px"> <div style = "position:relative">'); for(i = 0; i <n; i ++)document.write( '<div id = "ieface" style = "position:aspolute; top:0px; left:0; height:'+a+'; width:'+a+'; center">'+props+face [i]+'</b> </font> </div>'); document.write( '</div> </div>'); document.write( '</div> </div>'); document.write( '<div id = "oh" style = "position:absolute; top:0px; left:0px"> <div style = "position:relative">'); for(i = 0; i <h.length; i ++)document.write( '<div id = "iehours" style = "position:absolute; width:16px; height:16px; font-family:arial; font-size:16px; document.write( '</div> </div>'); document.write( '<div id = "om" style = "position:absolute; top:0px; left:0px"> <div style = "position:relative">'); for(i = 0; i <m.length; i ++)document.write( '<div id = "ieminutes" style = "position:absolute; width:16px; height:16px; font-family:arial; font-size:16px; document.write( '</div> </div>')document.write( '<div id = "os" style = "position:absolute; top:0px; left:0px"> <div style = "position:relative">'); (i = 0; i <s.length; i ++)document.write( '<div id = "ieseconds" style = "position:absolute; width:16px; height:16px; font-family:arial; font-size:16px; document.write( '</div> </div>')}(ns)?window.captureevents(event.mousemove):0; function mouse(evnt){ymouse =(ns)?evnt.pagey+clockfrommousey-(window.pageyoffset):event.y+clockfrommousey; xmouse =(ns)?evnt.pagex+clockfrommousex:event.x+clockfrommousex; }(ns)?window.onmousemove = mouse:document.onmousemove = mouse; function clockandassign(){time = new date(); sec = time.getSeconds(); sec = -1.57 + math.pi * sec/30; mins = time.getMinutes(); min = -1.57 + math.pi * mins/30; hr = time.gethours(); HRS = -1.575 + math.pi * HR/6 + Math.pi * parseint(time.getMinutes())/360; if(ie){od.style.top = window.document.body.scrolltop; of.style.top = window.document.body.scrolltop; oh.style.top = window.document.body.scrolltop; om.style.top = window.document.body.scrolltop; os.style.top = window.document.body.scrolltop; } for(i = 0; i <n; i ++){var f =(ns)?document.layers ['nsface'+i]:ieface [i] .style; f.top = y [i] + clockheight*math.sin(-1.0471 + i*split*math.pi/180) + scrll; f.left = x [i] + clockWidth*math.cos(-1.0471 + i*split*math.pi/180); } for(i = 0; i <h.length; i ++){var hl =(ns)?document.layers ['nshours'+i]:iehours [i] .style; hl.top = y [i]+handy+(i*handheight)*math.sin(hrs)+scrll; hl.left = x [i]+handx+(i*handwidth)*math.cos(hrs); } for(i = 0; i <m.length; i ++){var ml =(ns)?document.layers ['nsminutes'+i]:ieminutes [i] .style; ml.top = y [i]+handy+(i*handheight)*math.sin(min)+scrll; ml.left = x [i]+handx+(i*handwidth)*math.cos(min); } for(i = 0; i <s.length; i ++){var sl =(ns)?document.layers ['nsseconds'+i]:ieseconds [i] .style; sl.top = y [i]+handy+(i*handheight)*math.sin(sec)+scrll; sl.left = x [i]+handx+(i*handwidth)*math.cos(sec); } for(i = 0; i <d.length; i ++){var dl =(ns)?document.layers ['nsdate'+i]:iedate [i] .style; dl.top = dy [i]+clockheight*1.5*math.sin(currstep+i*dsplit*math.pi/180)+scrll; dl.left = dx [i] + clockWidth*1.5*math.cos(currStep + i*dsplit*math.pi/180); } currStep- = step; } function delay(){scrll =(ns)?window.pageyoffset:0; dy [0] = math.round(dy [0]+=((ymouse)-dy [0])*speed); dx [0] = math.round(dx [0]+=((xmouse)-dx [0])*speed); for(i = 1; i <d.length; i ++){dy [i] = math.round(dy [i]+=(dy [i-1] -dy [i])*speed); dx [i] = math.round(dx [i]+=(dx [i-1] -dx [i])*speed); } y [0] = math.round(y [0]+=((ymouse)-y [0])*speed); x [0] = math.round(x [0]+=((xmouse)-x [0])*speed); for(i = 1; i <n; i ++){y [i] = math.round(y [i]+=(y [i-1] -y [i])*speed); x [i] = math.round(x [i]+=(x [i-1] -x [i])*speed); } clockandassign(); setimeout( 'delay()'、40); } if(ns || ie)window.onload = delay; // - > </script>