- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- 현재 작성하고 있는 파일은 UTF-8 DOS파일입니다.-->
- <html xmlns="http://www.w3.org/1999/xhtml" lang="ko">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8" />
- </head>
- <body>
- <div id="ex_js_syntax">
- <script type="text/javascript" language="javascript">
- <!--
- function window_open_timeout(){
- /* 윈도우 창 열기 => window.open(); */
- open_timeout_specs = "width=550, height=200, top=300, left=300";
- open_timeout_window = window.open("", "open_timeout_window", open_timeout_specs, false);
- open_timeout_window.document.write("<p>open_timeout_window 창 열음</p>");
- document.getElementById("window_open_timeout").innerHTML = "창 열기";
- }
- function window_settimeout(){
- /* 윈도우 대기 후 한번만 실행 => window.setTimeout(반복할 function명, 대기시간 [밀리 초]); 1초=1000밀리초*/
- start_setinternal= setTimeout(window_repeat_timeout, 2000);
- open_timeout_window.focus();
- document.getElementById("window_settimeout").innerHTML = "settimeout() 대기 후 한번만 실행[클릭]";
- }
- function window_cleartimeout(){
- /* 윈도우 실행 중지 => window.clearTimeout(settimeout 변수); */
- clearTimeout(start_setinternal);
- open_timeout_window.document.write("<p>open_timeout_window 실행 중지</p>");
- open_timeout_window.focus();
- document.getElementById("window_cleartimeout").innerHTML = "cleartimeout() 실행 중지[클릭]";
- }
- function window_repeat_timeout(){
- /* 행동하기 위한 함수 */
- open_timeout_window.document.write("<p>open_timeout_window 대기 후 한번만 실행</p>");
- }
- //-->
- </script>
- <form name="input_type" id="input_type" method="post" >
- <!-- 예제 박스에선 안됨 => form태그안에 form태그있으면 지워짐~ㅠ.ㅠ -->
- 윈도우 => 대기 후 한번만 실행(2초후 실행) <br />
- <p id="window_open_timeout" onclick="window_open_timeout();">window객체-메서드 timeout()사용할 open()[클릭]</p>
- <p id="window_settimeout" onclick="window_settimeout();">window객체-메서드 settimeout() 대기 후 한번만 실행[클릭]</p>
- <p id="window_cleartimeout" onclick="window_cleartimeout();">window객체-메서드 cleartimeout() 실행 중지[클릭]</p>
- </form>
- </div>
- </body>
- </html>
--------------------------------------------------------------------------------------------
위 소스 예제 보기
특정 function를 대기 후 한번만 실행하고자 하는 경우 사용합니다.
윈도우 대기 후 한번만 실행 => window.setTimeout(반복할 function명, 대기시간 [밀리 초]);
1초=1000밀리초
윈도우 실행 중지 => window.clearTimeout(settimeout 변수);
window 속성 보기(접어두었습니다.)
출처 & 인용 - http://www.w3schools.com/
'javascript > window()객체' 카테고리의 다른 글
window객체 focus() 포커스 얻기 (0) | 2014.02.09 |
---|---|
window객체 btoa() atob() 베이스64[엔코딩 디코딩] (0) | 2014.02.09 |
window객체 setInterval() clearInterval() 반복 실행 [실행, 해제] (0) | 2014.02.08 |
window객체 scrollBy() scrollTo() 스크롤 위치[상대적, 절대적] (0) | 2014.02.08 |
window객체 resizeBy() resizeTo() 창크기[상대적, 절대적] (0) | 2014.02.08 |