웹 프론트엔드 JS 튜토리얼 마우스로 움직이는 시계는 매우 아름답습니다. 불행하게도 IE_javascript 트릭만 지원합니다.

마우스로 움직이는 시계는 매우 아름답습니다. 불행하게도 IE_javascript 트릭만 지원합니다.

May 16, 2016 pm 04:39 PM
시계 마우스 움직임

새 텍스트 파일을 만들고 다음 코드를 복사한 후 파일 이름을 clock.html로 변경하고 실행합니다.

<SCRIPT language=JavaScript><!-- 
dCol='0000FF';//date colour. 
fCol='0000FF';//face colour. 
sCol='0000FF';//seconds colour. 
mCol='0000FF';//minutes colour. 
hCol='0000FF';//hours colour. 
ClockHeight=40; 
ClockWidth=40; 
ClockFromMouseY=0; 
ClockFromMouseX=100; 
//Alter nothing below! Alignments will be lost! 
d=new Array("SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","SATURDAY"); 
m=new Array("JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"); 
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'; 
size=1; 
speed=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>"; 
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 < 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('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' 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='+a+' width='+a+'><center>'+props+Face[i]+'</font></center></layer>'); 
for (i=0; i < S.length; i++) 
document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+sCol+'><center><b>'+S[i]+'</b></center></font></layer>'); 
for (i=0; i < M.length; i++) 
document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+mCol+'><center><b>'+M[i]+'</b></center></font></layer>'); 
for (i=0; i < H.length; i++) 
document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+hCol+'><center><b>'+H[i]+'</b></center></font></layer>'); 
} 
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:absolute;top:0px;left:0;height:'+a+';width:'+a+';text-align:center">'+props+Face[i]+'</B></font></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;color:'+hCol+';text-align:center;font-weight:bold">'+H[i]+'</div>'); 
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;color:'+mCol+';text-align:center;font-weight:bold">'+M[i]+'</div>'); 
document.write('</div></div>') 
document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">'); 
for (i=0; i < S.length; i++) 
document.write('<div id="ieSeconds" style="position:absolute;width:16px;height:16px;font-family:Arial;font-size:16px;color:'+sCol+';text-align:center;font-weight:bold">'+S[i]+'</div>'); 
document.write('</div></div>') 
} 
(ns)&#63;window.captureEvents(Event.MOUSEMOVE):0; 
function Mouse(evnt){ 
ymouse = (ns)&#63;evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY; 
xmouse = (ns)&#63;evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX; 
} 
(ns)&#63;window.onMouseMove=Mouse:document.onmousemove=Mouse; 
function ClockAndAssign(){ 
time = new Date (); 
secs = time.getSeconds(); 
sec = -1.57 + Math.PI * secs/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)&#63;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)&#63;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)&#63;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)&#63;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)&#63;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)&#63;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(); 
setTimeout('Delay()',40); 
} 
if (ns||ie)window.onload=Delay; 
// --></SCRIPT>
로그인 후 복사
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
3 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

iPhone에 시계 앱이 없습니다. 해결 방법 iPhone에 시계 앱이 없습니다. 해결 방법 May 03, 2024 pm 09:19 PM

휴대폰에 시계 앱이 없나요? 날짜와 시간은 iPhone의 상태 표시줄에 계속 표시됩니다. 그러나 시계 앱이 없으면 세계 시계, 스톱워치, 알람 시계 및 기타 여러 기능을 사용할 수 없습니다. 따라서 누락된 시계 앱을 수정하는 것이 해야 할 일 목록의 맨 위에 있어야 합니다. 이러한 솔루션은 이 문제를 해결하는 데 도움이 될 수 있습니다. 수정 1 - 시계 앱 배치 실수로 홈 화면에서 시계 앱을 제거한 경우 시계 앱을 다시 제자리에 배치할 수 있습니다. 1단계 – iPhone을 잠금 해제하고 앱 라이브러리 페이지에 도달할 때까지 왼쪽으로 스와이프합니다. 2단계 – 다음으로 검색창에 “시계”를 검색하세요. 3단계 – 검색 결과 아래에 “시계”가 표시되면 길게 누르고

iOS 17이 설치된 iPhone에서 여러 타이머를 사용하는 방법 iOS 17이 설치된 iPhone에서 여러 타이머를 사용하는 방법 Jun 21, 2023 am 08:18 AM

iOS17의 멀티 타이머란 무엇입니까? iOS17에서 Apple은 이제 사용자에게 iPhone에서 한 번에 여러 타이머를 설정할 수 있는 기능을 제공합니다. 이는 많은 사람들이 수년 동안 기다려온 환영할 만한 변화입니다. iOS 16 이전에는 사용자가 한 번에 하나의 타이머만 설정할 수 있었던 시계 앱을 이제 원하는 수의 타이머를 활성화하는 데 사용할 수 있으므로 한 번에 여러 작업을 완료하는 데 이상적입니다. 타이머 화면에서 타이머를 원하는 만큼 설정할 수 있습니다. 타이머가 시작되면 모든 활성 타이머가 잠금 화면 및 알림 센터에 "실시간 활동" 알림으로 표시됩니다. 여기에서 시계 앱을 열지 않고도 타이머가 꺼질 때까지 남은 시간을 확인하거나 타이머를 일시 중지하거나 중지할 수 있습니다. 당신이 시계에있을 때

iOS 17: 대기 모드에서 iPhone 시계 스타일을 변경하는 방법 iOS 17: 대기 모드에서 iPhone 시계 스타일을 변경하는 방법 Sep 10, 2023 pm 09:21 PM

대기는 iPhone이 충전기에 연결되어 있고 가로(또는 가로) 방향일 때 활성화되는 잠금 화면 모드입니다. 세 가지 화면으로 구성되어 있으며 그 중 하나는 전체 화면 시간으로 표시됩니다. 시계 스타일을 변경하는 방법을 알아보려면 계속 읽어보세요. StandBy의 세 번째 화면에는 수직으로 스와이프할 수 있는 다양한 테마의 시간과 날짜가 표시됩니다. 일부 테마에는 온도나 다음 알람과 같은 추가 정보도 표시됩니다. 시계를 길게 누르면 디지털, 아날로그, 세계, 태양광, 플로팅 등 다양한 테마 간에 전환할 수 있습니다. Float는 사용자 정의 가능한 색상의 큰 거품 숫자로 시간을 표시하고, Solar는 다양한 색상의 태양 플레어 디자인을 갖춘 보다 표준적인 글꼴을 가지며, World는 강조 표시하여 세계를 표시합니다.

iPhone에서 알람을 끄는 방법 [2023] iPhone에서 알람을 끄는 방법 [2023] Aug 21, 2023 pm 01:25 PM

스마트폰이 등장한 이후 스마트폰은 의심할 여지없이 알람시계를 대체해 왔습니다. iPhone을 소유하고 있다면 시계 앱을 사용하여 하루 종일 여러 상황에 대해 원하는 만큼의 알람을 쉽게 설정할 수 있습니다. 이 앱을 사용하면 알람 시간, 신호음, 반복 빈도, 스누즈 옵션을 사용하여 알람을 지연할지 여부를 구성할 수 있습니다. 설정한 알람을 끄고 싶다면 다음 게시물을 참조하여 iPhone에서 일반 알람과 모닝콜 알람을 비활성화하고 삭제하는 데 도움이 될 것입니다. iPhone에서 일반 알람을 끄는 방법 기본적으로 시계 앱에 알람을 추가하거나 Siri에게 알람 추가를 요청하면 실제로 일반 알람이 생성됩니다. iPhone에서 원하는 만큼의 알람 시계를 만들고 추가할 수 있습니다.

iOS 17에서 대기 색상을 사용자 정의하는 방법 iOS 17에서 대기 색상을 사용자 정의하는 방법 Sep 23, 2023 pm 12:53 PM

Apple은 iOS 17에서 대기 모드라는 새로운 잠금 화면 모드를 제공합니다. 이 모드는 iPhone을 충전기(유선 또는 무선)에 연결하고 스탠드에 가로 방향으로 놓았을 때 활성화됩니다. 이 모드에서는 시계, 날씨 데이터, 달력, 일부 위젯을 표시하여 표준 잠금 화면보다 더 많은 정보를 한 눈에 볼 수 있습니다. 설정에서 이 기능을 활성화한 후 충전하는 동안 iPhone을 가로 방향으로 놓으면 자동으로 대기 모드로 전환됩니다. iOS 17 대기 모드에서 대기 색상을 변경하는 방법은 화면을 스와이프하여 앞뒤로 전환할 수 있는 세 가지 페이지(위젯, 사진, 시계) 세트를 제공합니다. 이 페이지 중 시계 화면에서만 화면에 표시되는 색상을 사용자 정의할 수 있습니다.

win10 컴퓨터 시계가 항상 정확하지 않으면 어떻게 해야 합니까? win10 컴퓨터 시간을 조정하는 몇 가지 방법이 있습니까? win10 컴퓨터 시계가 항상 정확하지 않으면 어떻게 해야 합니까? win10 컴퓨터 시간을 조정하는 몇 가지 방법이 있습니까? Mar 27, 2024 pm 05:10 PM

1. 먼저 시작 메뉴를 클릭하고 시작 메뉴에서 설정 버튼을 선택합니다. 2. 개봉 후, 시간과 언어 설정을 선택하세요. 3. 시간이 자동으로 설정되도록 변경하세요. 4. 자동 시간 설정을 끄고 변경하려는 시간을 선택할 수도 있습니다. 방법 2: 1. [기타 날짜, 시간 및 지역 설정] 옵션을 엽니다. 2. [시간 및 날짜 설정]을 선택하세요. 3. [인터넷 시간]을 선택하고 [설정 변경 옵션]을 엽니다. 4. [인터넷 시간 서버(S)와 동기화]를 선택하고 [지금 업데이트]를 클릭한 후 확인을 클릭하세요.

TikTok 라벨 뒤에 시계를 설정하는 방법은 무엇입니까? 트래픽을 유도하기 위해 태그를 설정하는 방법은 무엇입니까? TikTok 라벨 뒤에 시계를 설정하는 방법은 무엇입니까? 트래픽을 유도하기 위해 태그를 설정하는 방법은 무엇입니까? Mar 25, 2024 pm 05:21 PM

세계에서 가장 인기 있는 단편 비디오 플랫폼 중 하나인 Douyin의 강력한 기능과 풍부한 게임 플레이로 인해 사용자는 쉽게 내려놓을 수 없습니다. Douyin에서는 작품에 태그를 추가하여 노출을 늘릴 수 있으며, 태그 뒤의 시계는 태그 아래 콘텐츠의 업데이트 시간을 알려줍니다. 그렇다면 Douyin 라벨 뒤에 시계를 설정하는 방법은 무엇입니까? 이 글에서는 Douyin 태그와 시계를 설정하는 방법, 태그를 통해 트래픽을 유도하는 방법을 자세히 소개합니다. 1. Douyin 라벨 뒤에 시계를 설정하는 방법은 무엇입니까? 1. Douyin을 열고 "만들기" 버튼을 클릭하여 비디오 편집 페이지로 들어갑니다. 2. 자료 선택 후 '다음'을 클릭하여 작품 공개 페이지로 이동합니다. 3. 작품 출판 페이지에서 작품 제목을 입력하고 '태그 추가'를 클릭하세요. 4. 라벨 페이지에서 추가하려는 라벨의 이름을 입력하세요.

정확한 타이밍: PHP DateTime 확장의 시계 비밀 정확한 타이밍: PHP DateTime 확장의 시계 비밀 Mar 08, 2024 am 10:01 AM

PHP의 타이밍 이해 PHPDateTime 확장은 시간 데이터를 처리하고 다양한 시간 작업을 수행하기 위한 강력하고 유연한 프레임워크를 제공합니다. 핵심 구성 요소 중 하나는 시스템 시간을 추적하고 타임스탬프를 조작하고 변환하는 방법을 제공하는 시계입니다. DateTime clockDateTime 시계는 시스템 내의 시간 소스를 나타내는 추상적인 개념입니다. 이는 네 가지 주요 메소드를 제공합니다: now(): 현재 시간의 DateTime 객체를 가져옵니다. createFromFormat(): 주어진 형식에 따라 문자열을 구문 분석하고 DateTime 객체를 생성합니다. createFromImmutable(): 불변의 DateTimeImmuta

See all articles