JavaScript

일정 시간이 경과후에 함수 호출

tomato13 2008. 8. 26. 21:49

http://blog.naver.com/ktw5724?Redirect=Log&logNo=120035320009

 

ex) 페이지 로딩시작 10초 경과후 alert창 노출

function test_alert()

{

  alert("test alert");

}

function test_stop()

  if ( mark ) clearTimeout(mark);

}

var mark = setTimeout("test_alert()", 10000);   // 10초후 함수호출

 

p.s) while문을 사용하여 시간을 계산하여 pause 혹은 sleep을 유도하는 방법도 있겠으나 효과적이지 않은 듯 하다. 예를 들어 이 경우에는 browser에 나타나야할 내용들이 나타나지 않는 현상이 있었다.

'JavaScript' 카테고리의 다른 글

슬라이드쇼  (0) 2011.06.10
구구단 샘플  (0) 2011.06.10
html script, javasciprt 수행 순서  (0) 2008.08.26
document.location.href  (0) 2008.08.26
The ActiveXObject() Function  (0) 2008.08.25