Javascript
(Javascript) setTimeout, setInterval, clearInterval 자바스크립트 타이머
SAFE
2016. 4. 29. 12:15
언젠간 쓸 일이 있을 함수인데 찾아놨다.
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() 함수를 실행합니다.
...
});
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 |