window 객체의 타이머 기능 2 가지
- 타임아웃 코드 1회 호출 : setTimeout()/clearTimeout() 메소드
- 타임 아웃 코드 반복 호출 : setInterval()/clearInterval() 메소드
setTimeout()/clearTimeout()
- setTimeout() : 타임아웃 코드 1회 실행
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
onmouseover="startTimer(5000)"
onmouseout="cancelTimer()">
<script>
var timerID = null;
//timerID : 시간
function startTimer(time){
document.getElementById("img").title = "타이머 작동 시작";
}
function cancelTimer(){
if(timerID!=null){
clearTimeout(timerID); // 타이머 중단
}
}
function load(url){
location.href = url;//현재 윈도우가 url 사이트로 이동
}
</script>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'화면구현' 카테고리의 다른 글
location 객체 (0) | 2020.03.16 |
---|---|
웹 페이지 스크롤 (0) | 2020.03.16 |
윈도우 열기 (0) | 2020.03.16 |
계산기 만들기 (0) | 2020.03.12 |
라디오버튼과 체크박스 (0) | 2020.03.12 |