- <!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_focus(){
- /* 윈도우 포커스 => window.focus();
- window open으로 설명할까 했지만 새창 열리면 그쪽으로 포커스가 되어서
- 설명하기 위해서 요소에 포커스 주는 것으로 대신함
- open_moveby_specs = "width=350, height=200, top=300, left=300";
- open_moveby_window = window.open("", "open_moveby_window", open_moveby_specs, false);
- open_moveby_window.document.write("<p>open_moveby_window 창 열음</p>");
- open_moveby_window.focus();
- window 객체를 이용한 방법은 위와 같습니다.(focus3참조) */
- document.getElementById("focus_text").focus();
- }
- //-->
- function window_focus2(){
- /* 윈도우 포커스 => window.focus(); */
- document.getElementById("focus_text2").focus();
- }
- function window_focus3(){
- /* 윈도우 포커스 => window.focus(); */
- open_moveby_specs = "width=350, height=200, top=300, left=300";
- open_moveby_window = window.open("", "open_moveby_window", open_moveby_specs, false);
- open_moveby_window.document.write("<p>open_moveby_window 창 열음</p>");
- open_moveby_window.focus();
- document.getElementById("window_focus3").innerHTML = "새창 포커스";
- /* 3초 후 새창 닫기 */
- setTimeout(function(){open_moveby_window.close();}, 3000);
- /* 3초 후 포커스 텍스트 박스에 주기 */
- setTimeout(function(){document.getElementById("focus_text").focus();}, 3000);
- }
- //-->
- </script>
- <form name="input_type" id="input_type" method="post" >
- <!-- 예제 박스에선 안됨 => form태그안에 form태그있으면 지워짐~ㅠ.ㅠ -->
- 윈도우 => 포커스 <br />
- <p id="window_focus" onclick="window_focus();">window객체-메서드 focus()[클릭]</p>
- <p id="window_focus2" onclick="window_focus2();">window객체-메서드 focus2()[클릭]</p>
- <input type="text" name="focus_text" id="focus_text" value="focus_text" />
- <input type="text2" name="focus_text2" id="focus_text2" value="focus_text2" />
- <p id="window_focus3" onclick="window_focus3();">window객체-메서드 focus3()[클릭]</p>
- </form>
- </div>
- </body>
- </html>
--------------------------------------------------------------------------------------------
위 소스 예제 보기
윈도우 포커스를 얻습니다. => window.focus();
window 속성 보기(접어두었습니다.)
출처 & 인용 - http://www.w3schools.com/
'javascript > window()객체' 카테고리의 다른 글
window객체 브라우저 창크기 정보 (0) | 2014.02.16 |
---|---|
window객체 onload 로딩후 실행 (예제없음) (0) | 2014.02.10 |
window객체 btoa() atob() 베이스64[엔코딩 디코딩] (0) | 2014.02.09 |
window객체 setTimeout() clearTimeout() 대기 후 한번만 실행 [실행, 해제] (0) | 2014.02.08 |
window객체 setInterval() clearInterval() 반복 실행 [실행, 해제] (0) | 2014.02.08 |