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_interval(){
  12.        /* 윈도우 창 열기 => window.open(); */
  13.        open_interval_specs = "width=550, height=200, top=300, left=300";
  14.        open_interval_window = window.open("", "open_interval_window", open_interval_specs, false);
  15.        open_interval_window.document.write("<p>open_interval_window 창 열음</p>");
  16.        document.getElementById("window_open_interval").innerHTML = "창 열기";
  17.       }
  18.       function window_setinterval(){
  19.        /* 윈도우 반복 시작 => window.setInterval(반복할 function명, 실행시간 [밀리 초]); 1초=1000밀리초 */
  20.        start_setinternal= setInterval(window_repeat_interval, 2000);
  21.        open_interval_window.focus();
  22.        document.getElementById("window_setinterval").innerHTML = "setInterval() 반복 시작[클릭]";
  23.       }
  24.       function window_clearinterval(){
  25.        /* 윈도우 반복 중지 => window.clearInterval(setInterval 변수); */
  26.        clearInterval(start_setinternal);
  27.        open_interval_window.document.write("<p>open_interval_window 반복 중지</p>");
  28.        open_interval_window.focus();
  29.        document.getElementById("window_clearinterval").innerHTML = "clearInterval() 반복 중지[클릭]";
  30.       }
  31.       function window_repeat_interval(){
  32.        /* 행동하기 위한 함수 */
  33.        open_interval_window.document.write("<p>open_interval_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_interval" onclick="window_open_interval();">window객체-메서드 interval()사용할 open()[클릭]</p>
  41.         <p id="window_setinterval" onclick="window_setinterval();">window객체-메서드 setInterval() 반복 시작[클릭]</p>
  42.         <p id="window_clearinterval" onclick="window_clearinterval();">window객체-메서드 clearInterval() 반복 중지[클릭]</p>
  43.       </form>
  44.     </div>
  45.   </body>
  46. </html>

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

위 소스 예제 보기


setInterval()

clearInterval()


특정 function를 반복 실행 하고자 하는 경우 사용합니다.


윈도우 반복 시작 => window.setInterval(반복할 function명, 실행시간 [밀리 초]); 

                            1초=1000밀리초

윈도우 반복 중지 => window.clearInterval(setInterval 변수);


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 :