1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <!-- 현재 작성하고 있는 파일은 UTF-8 DOS파일입니다.-->
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="ko">
  4.   <head>
  5.     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.   </head>
  7.   <body>
  8.     <div id="ex_js_syntax">
  9.       <script type="text/javascript" language="javascript">
  10.       <!--
  11.       function window_open_timeout(){
  12.        /* 윈도우 창 열기 => window.open(); */
  13.        open_timeout_specs = "width=550, height=200, top=300, left=300";
  14.        open_timeout_window = window.open("", "open_timeout_window", open_timeout_specs, false);
  15.        open_timeout_window.document.write("<p>open_timeout_window 창 열음</p>");
  16.        document.getElementById("window_open_timeout").innerHTML = "창 열기";
  17.       }
  18.       function window_settimeout(){
  19.        /* 윈도우 대기 후 한번만 실행 => window.setTimeout(반복할 function명, 대기시간 [밀리 초]); 1초=1000밀리초*/
  20.        start_setinternal= setTimeout(window_repeat_timeout, 2000);
  21.        open_timeout_window.focus();
  22.        document.getElementById("window_settimeout").innerHTML = "settimeout() 대기 후 한번만 실행[클릭]";
  23.       }
  24.       function window_cleartimeout(){
  25.        /* 윈도우 실행 중지 => window.clearTimeout(settimeout 변수); */
  26.        clearTimeout(start_setinternal);
  27.        open_timeout_window.document.write("<p>open_timeout_window 실행 중지</p>");
  28.        open_timeout_window.focus();
  29.        document.getElementById("window_cleartimeout").innerHTML = "cleartimeout() 실행 중지[클릭]";
  30.       }
  31.       function window_repeat_timeout(){
  32.        /* 행동하기 위한 함수 */
  33.        open_timeout_window.document.write("<p>open_timeout_window 대기 후 한번만 실행</p>");
  34.       }
  35.       //-->
  36.       </script>
  37.       <form name="input_type" id="input_type" method="post" >
  38.       <!-- 예제 박스에선 안됨 => form태그안에 form태그있으면 지워짐~ㅠ.ㅠ -->
  39.         윈도우 => 대기 후 한번만 실행(2초후 실행) <br />
  40.         <p id="window_open_timeout" onclick="window_open_timeout();">window객체-메서드 timeout()사용할 open()[클릭]</p>
  41.         <p id="window_settimeout" onclick="window_settimeout();">window객체-메서드 settimeout() 대기 후 한번만 실행[클릭]</p>
  42.         <p id="window_cleartimeout" onclick="window_cleartimeout();">window객체-메서드 cleartimeout() 실행 중지[클릭]</p>
  43.       </form>
  44.     </div>
  45.   </body>
  46. </html>

--------------------------------------------------------------------------------------------

위 소스 예제 보기


setTimeout()

clearTimeout()


특정 function를 대기 후 한번만 실행하고자 하는 경우 사용합니다.


윈도우 대기 후 한번만 실행 => window.setTimeout(반복할 function명, 대기시간 [밀리 초]); 

                                          1초=1000밀리초

윈도우 실행 중지 => window.clearTimeout(settimeout 변수);


window 속성 보기(접어두었습니다.)


출처 & 인용 - http://www.w3schools.com/


:
BLOG main image

공지사항

카테고리

분류 (356)
main (1)
php5 (218)
HTML (36)
javascript (93)
IT 이론과 퍼온정보 (8)
깨작일상 (0)
곧 추가할 내용 (0)
추후 알아볼것들... (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

달력

«   2024/03   »
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
31
Total :
Today : Yesterday :