Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- web
- Linux
- SSH
- Network Info(Tool)
- webhard
- Command
- Crack(Serial Key)
- FTP
- calculator
- H/W
- apm
- OS(operating system)
- game
- Programming
- LiveCD(USB)
- network
- portable
- MS Windows PE
- Update
- PC
- Backup(Restore)
- UNIX
- explorer
- MS windows
- script
- 대항해시대
- Disk Partition
- Windows 10
- program
- javascript
Archives
- Today
- Total
<In Story>
자바스크립트 딜레이 하기, Javascript Delay function // [Programming] [Script] [Web] [JavaScript] 본문
Programming/Web
자바스크립트 딜레이 하기, Javascript Delay function // [Programming] [Script] [Web] [JavaScript]
<In Story, Hi story, History> 2015. 10. 4. 18:07function delay(_delay_gap) { /* gap is in millisecs */
var _then,_now;
_then = new Date().getTime();
_now = _then;
while((_now - _then) < _delay_gap) {
_now = new Date().getTime();
}
return;
}
시간이 지난후에 함수를 한번 실행시켜 주는 함수
window.setTimeout("function name", delay_time); /* gap is in millisecs, window prefix를 생략하고 사용할 수 있다. */
setTimeout("myFunction()", 3000); // 3초후 myFunction() 함수 실행
setTimeout(function(){console.log('안녕하세요')}, 1000); // 1초후 "안녕하세요" 출력
시간마다 함수를 한번씩 실행시켜 주는 함수
window.setInterval("function name", delay_time); /* gap is in millisecs, window prefix를 생략하고 사용할 수 있다. */
setInterval("myFunction()", 3000); // 3초마다 myFunction() 함수 실행
setInterval(function(){console.log('안녕하세요')}, 1000); // 1초마다 "안녕하세요" 출력