본문 바로가기

Javascript

(Javascript) setTimeout, setInterval, clearInterval 자바스크립트 타이머

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
언젠간 쓸 일이 있을 함수인데 찾아놨다.

1) setTimeout([Function], [Milliseconds])

2) setInterval([Function], [Milliseconds])
  $$$$$$$$$$$
>> setInterval(function(){$("#append").click()}, 2000); 


3) clearInterval([Timer Id])


$(document).ready(function() {
      ...
 
    setInterval("ozit_interval_test()", 5000); 
    // 매 5000ms(5초)가 지날 때마다 ozit_timer_test() 함수를 실행합니다.
 
 ...
});


출처 : http://ooz.co.kr/194

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<script type="text/javascript">
$(document).ready(function() {
      ...
 
setTimeout("ozit_timer_test()"3000); // 3000ms(3초)가 경과하면 ozit_timer_test() 함수를 실행합니다.
 
 ...
});
 
function ozit_timer_test(){
alert("오즈의 순위왕 블로그로 이동합니다.");
location.href = "http://ozrank.co.kr"// 오즈의 순위왕 블로그로 이동합니다.
}
 
</script>
cs