• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Document] JS - hasFocus() 메서드 ★ - 포커스 상태인지 체크 (= hasFocus메서드 = 해즈포커스메서드) ※ 조건 분기 글쓰기

목차
  1. hasFocus() 예제 - 포커스 여부 체크
  2. hasFocus() 정의
  3. hasFocus() 구문

 

hasFocus() 예제 - 포커스 여부 체크 

 

<p id="hz"></p>


<script>

setInterval("homzzang()", 1);


function homzzang() {

    var x = document.getElementById("hz");

    if (document.hasFocus()) {

        x.innerHTML = "홈짱닷컴 Homzzang.com";

    } else {

        x.innerHTML = "홈짱닷컴 주소 보기 (클릭)";

    }

}

</script>


결과보기

 

hasFocus() 정의


해당 문서나 요소가 포커스 상태인지 판별.

 

 

hasFocus() 구문

 

document.hasFocus()

 


[매개변수]

 

없음.

 


[반환값]

 

웹문서 또는 웹문서의 요소에 포커스가 있는지 여부 반환.

  • 포커스 존재 O 시, TRUE 반환.
  • 포커스 존재 X 시, FALSE 반환.

 



분류 제목
Window_Console JS - console.timeEnd() 메서드 - 콘솔창에서 타이머 종료 후 기록 쓰기 (= console…
Window_Console JS - console.trace() 메서드 - 코드 실행 내역 역추적해 콘솔에 표시 (= console.t…
Window_Console JS - console.warn() 메서드 - 콘솔에 경고 쓰기 (= console.warn메서드 = 콘솔원…
DOM_Document JS - activeElement 속성 ★ - 현재포커스요소 반환 (= 액티브엘러먼트속성)
DOM_Document JS - addEventListener() 메서드 ★ - document에 이벤트 걸기. (= addEven…
DOM_Document JS - adoptNode() 메서드 ★ - 다른문서의 노드 잘라내서 가져오기 (IE9 이상) ※ 아이프레임…
DOM_Document JS - anchors 속성 - name 속성 갖은 모든 앵커태그집합 반환 (=anchors속성 = 앵커즈 …
DOM_Document JS - applets 속성 - 모든 애플릿태그집합 반환
DOM_Document JS - baseURI 속성 - 웹문서 기본URI 반환 (IE 지원X)
DOM_Document JS - body 속성 - 웹문서본문 설정/반환
DOM_Document JS - close() 메서드 - 웹문서출력모드 닫고 수집된 데이터 표시
DOM_Document JS - document.cookie 속성 ★ - (쿠키이름/쿠키값) 쌍을 설정/반환 (= document.…
DOM_Document JS - charset 속성 - 문자셋 (= 언어셋) 반환 (IE9 이상)
DOM_Document JS - characterSet 속성 - 문자셋 (= 언어셋) 반환 (IE9 이상)
DOM_Document JS - createAttribute() 메서드 ★ - 속성생성 (예: 클릭색상변경)
DOM_Document JS - createComment() 메서드 - 주석생성
DOM_Document JS - createDocumentFragment() 메서드 - 가상노드생성
DOM_Document JS - createElement() 메서드 ★ - 요소생성 (= createElement메서드 = 크리에이…
DOM_Document JS - createEvent() 메서드 - 이벤트객체생성 (예: 마우스오버횟수구하기)
DOM_Document JS - createTextNode() 메서드 - 텍스트노드생성
24/67
목록
찾아주셔서 감사합니다. Since 2012