สร้างไฟล์ข้อความใหม่คัดลอกรหัสต่อไปนี้และเปลี่ยนชื่อไฟล์เป็น clock.html และเรียกใช้
<ภาษาสคริปต์ = JavaScript> <!- dcol = '0000ff'; // สีวันที่ fcol = '0000ff'; // สีใบหน้า scol = '0000ff'; // สีวินาที mcol = '0000ff'; // นาทีสี hcol = '0000ff'; // ชั่วโมงสี clockHeight = 40; Clockwidth = 40; clockfrommousey = 0; clockfommousex = 100; // เปลี่ยนแปลงอะไรที่อยู่ด้านล่าง! การจัดตำแหน่งจะหายไป! D = New Array ("Sunday", "Monday", "Tuesday", "วันพุธ", "วันพฤหัสบดี", "วันศุกร์", "วันเสาร์"); M = New Array ("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"); วันที่ = วันที่ใหม่ (); day = date.getDate (); ปี = date.geteyear (); ถ้า (ปี <2000) ปี = ปี+1900; todaysdate = ""+d [date.getday ()]+""+วัน+""+m [date.getMonth ()]+""+ปี; 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 = ขนาด*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 = array ใหม่ (); y = array ใหม่ (); x = new Array (); สำหรับ (i = 0; i <n; i ++) {y [i] = 0; x [i] = 0; y [i] = 0; x [i] = 0} dy = อาร์เรย์ใหม่ (); dx = new Array (); dy = array ใหม่ (); dx = new Array (); สำหรับ (i = 0; i <d.length; i ++) {dy [i] = 0; dx [i] = 0; dy [i] = 0; dx [i] = 0} ถ้า (ns) {สำหรับ (i = 0; i <d.length; i ++) เอกสาร width = '+a+'> <center> '+props2+d [i]+' </font> </enter> </layer> '); สำหรับ (i = 0; i <n; i ++) document.write ('<layer name = "nsface'+i+'" top = 0 left = 0 ความสูง ='+a+'width ='+a+'> <center>'+props+face [i]+'</font> สำหรับ (i = 0; i <s.length; i ++) document.write ('layer name = nsseconds'+i+'top = 0 ซ้าย = 0 width = 15 ความสูง = 15> <font face = arial size = 3 color ='+scol+'> <center> <b>'+s [i]+'</b> สำหรับ (i = 0; i <m.length; i ++) document.write ('layer name = nsminutes'+i+'top = 0 ซ้าย = 0 width = 15 ความสูง = 15> <font face = ขนาด arial = 3 color ='+mcol+'> <center> <b>'+m [i]+'</b> สำหรับ (i = 0; i <h.length; i ++) document.write ('<layer name = nshours'+i+'top = 0 ซ้าย = 0 width = 15 ความสูง = 15> <font face = ขนาด arial = 3 color ='+hcol+'> <center> <b>'+h [i]+'</b> } if (เช่น) {document.write ('<div id = "od" style = "ตำแหน่ง: Absolute; top: 0px; ซ้าย: 0px"> <div style = "ตำแหน่ง: ญาติ">'); สำหรับ (i = 0; i <d.length; i ++) document.write ('<div id = "iedate" style = "ตำแหน่ง: Absolute; top: 0px; ซ้าย: 0; ความสูง:'+a+'; width:'+a+'; text-align: center">'+props2+d [i]+'</b> document.write ('</div> </div>'); document.write ('<div id = "ของ" style = "ตำแหน่ง: สัมบูรณ์; top: 0px; ซ้าย: 0px"> <div style = "ตำแหน่ง: ญาติ">'); สำหรับ (i = 0; i <n; i ++) document.write ('<div id = "ieface" style = "ตำแหน่ง: Absolute; top: 0px; ซ้าย: 0; ความสูง:'+a+'; ความกว้าง:'+a+'; text-align: center">'+props+face [i]+'</b> document.write ('</div> </div>'); document.write ('</div> </div>'); document.write ('<div id = "oh" style = "ตำแหน่ง: สัมบูรณ์; top: 0px; ซ้าย: 0px"> <div style = "ตำแหน่ง: ญาติ">'); สำหรับ (i = 0; i <h.length; i ++) document.write ('<div id = "iehours" style = "ตำแหน่ง: สัมบูรณ์; ความกว้าง: 16px; ความสูง: 16px; แบบอักษรครอบครัว: Arial; Font-Size: 16px; สี:'+hcol+'; document.write ('</div> </div>'); document.write ('<div id = "om" style = "ตำแหน่ง: สัมบูรณ์; top: 0px; ซ้าย: 0px"> <div style = "ตำแหน่ง: ญาติ">'); สำหรับ (i = 0; i <m.length; i ++) document.write ('<div id = "ieminutes" style = "ตำแหน่ง: สัมบูรณ์; ความกว้าง: 16px; ความสูง: 16px; แบบอักษร: Arial; Font-Size: 16px; สี:'+mcol+'; document.write ('</div> </div>') document.write ('<div id = "os" style = "ตำแหน่ง: Absolute; top: 0px; ซ้าย: 0px"> <div style = "ตำแหน่ง: ญาติ">'); สำหรับ (i = 0; i <s.length; i ++) document.write ('<div id = "ieseconds" style = "ตำแหน่ง: สัมบูรณ์; ความกว้าง: 16px; ความสูง: 16px; แบบอักษรครอบครัว: Arial; Font-Size: 16px; สี:'+scol+'; document.write ('</div> </div>')} (ns)? window.captureevents (event.mousemove): 0; ฟังก์ชั่นเมาส์ (evnt) {ymouse = (ns)? evnt.pagey+clockfrommousey- (window.pageyoffset): event.y+clockfrommousey; xmouse = (ns)? evnt.pagex+clockfrommousex: event.x+clockfommousex; } (ns)? window.onmousemove = เมาส์: document.onmousemove = เมาส์; ฟังก์ชั่น 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 (เช่น) {od.style.top = window.document.body.scrolltop; ของ. 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; } สำหรับ (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); } สำหรับ (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 (ชั่วโมง); } สำหรับ (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); } สำหรับ (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 (วินาที)+scrll; sl.left = x [i]+handx+(i*handwidth)*math.cos (วินาที); } สำหรับ (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- = ขั้นตอน; } function delay () {scrll = (ns)? window.pageyoffset: 0; dy [0] = math.round (dy [0]+= ((ymouse) -dy [0])*ความเร็ว); dx [0] = math.round (dx [0]+= ((xmouse) -dx [0])*ความเร็ว); สำหรับ (i = 1; i <d.length; i ++) {dy [i] = math.round (dy [i]+= (dy [i-1] -dy [i])*ความเร็ว); dx [i] = math.round (dx [i]+= (dx [i-1] -dx [i])*ความเร็ว); } y [0] = math.round (y [0]+= ((ymouse) -y [0])*ความเร็ว); x [0] = math.round (x [0]+= ((xmouse) -x [0])*ความเร็ว); สำหรับ (i = 1; i <n; i ++) {y [i] = math.round (y [i]+= (y [i-1] -y [i])*ความเร็ว); x [i] = math.round (x [i]+= (x [i-1] -x [i])*ความเร็ว); } clockandassign (); settimeout ('delay ()', 40); } if (ns || ie) window.onload = ล่าช้า; // -> </script>