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_focus(){
  12.        /* 윈도우 포커스 => window.focus(); 
  13.           window open으로 설명할까 했지만 새창 열리면 그쪽으로 포커스가 되어서
  14.           설명하기 위해서 요소에 포커스 주는 것으로 대신함 
  15.           open_moveby_specs = "width=350, height=200, top=300, left=300";
  16.           open_moveby_window = window.open("", "open_moveby_window", open_moveby_specs, false);
  17.           open_moveby_window.document.write("<p>open_moveby_window 창 열음</p>");
  18.           open_moveby_window.focus();  
  19.           window 객체를 이용한 방법은 위와 같습니다.(focus3참조) */
  20.        document.getElementById("focus_text").focus();
  21.       }
  22.       //-->
  23.       function window_focus2(){
  24.        /* 윈도우 포커스 => window.focus(); */
  25.        document.getElementById("focus_text2").focus();
  26.       }
  27.       function window_focus3(){
  28.        /* 윈도우 포커스 => window.focus(); */
  29.        open_moveby_specs = "width=350, height=200, top=300, left=300";
  30.        open_moveby_window = window.open("", "open_moveby_window", open_moveby_specs, false);
  31.        open_moveby_window.document.write("<p>open_moveby_window 창 열음</p>");
  32.        open_moveby_window.focus();  
  33.        document.getElementById("window_focus3").innerHTML = "새창 포커스";
  34.        /* 3초 후 새창 닫기 */
  35.        setTimeout(function(){open_moveby_window.close();}, 3000);
  36.        /* 3초 후 포커스 텍스트 박스에 주기 */
  37.        setTimeout(function(){document.getElementById("focus_text").focus();}, 3000);
  38.       }
  39.       //-->
  40.       </script>
  41.       <form name="input_type" id="input_type" method="post" >
  42.       <!-- 예제 박스에선 안됨 => form태그안에 form태그있으면 지워짐~ㅠ.ㅠ -->
  43.         윈도우 => 포커스 <br />
  44.         <p id="window_focus" onclick="window_focus();">window객체-메서드 focus()[클릭]</p>
  45.         <p id="window_focus2" onclick="window_focus2();">window객체-메서드 focus2()[클릭]</p>
  46.         <input type="text" name="focus_text" id="focus_text" value="focus_text" />
  47.         <input type="text2" name="focus_text2" id="focus_text2" value="focus_text2" />
  48.         <p id="window_focus3" onclick="window_focus3();">window객체-메서드 focus3()[클릭]</p>
  49.       </form>
  50.     </div>
  51.   </body>
  52. </html>

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

위 소스 예제 보기


window.focus()


윈도우 포커스를 얻습니다. => window.focus();


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


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


:
BLOG main image

공지사항

카테고리

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

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

달력

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