diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
| commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
| tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/api/document/hasfocus | |
| parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
| download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip | |
initial commit
Diffstat (limited to 'files/ko/web/api/document/hasfocus')
| -rw-r--r-- | files/ko/web/api/document/hasfocus/index.html | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/files/ko/web/api/document/hasfocus/index.html b/files/ko/web/api/document/hasfocus/index.html new file mode 100644 index 0000000000..b41818b736 --- /dev/null +++ b/files/ko/web/api/document/hasfocus/index.html @@ -0,0 +1,101 @@ +--- +title: Document.hasFocus() +slug: Web/API/Document/hasFocus +tags: + - API + - DOM + - Focus + - Method + - Reference +translation_of: Web/API/Document/hasFocus +--- +<p>{{ ApiRef("DOM") }}</p> + +<p><code><strong>Document.hasFocus()</strong></code> 메소드는 문서 또는 문서 내의 요소(element) 중 어느 하나라도 포커스(focus)를 갖고 있으면 <code>true, </code>그렇지 않으면<code> false</code>인 {{jsxref("Boolean")}} 값을 반환한다. 이 메소드를 사용하여 문서내 활성화된(active) 요소가 포커스를 갖고 있는지 판단할 수 있다.</p> + +<div class="note"> +<p>문서를 볼 때, 포커스를 가진 요소는 언제나 문서상의 활성화된 요소이다. 반면에 활성화된 요소는 꼭 포커스를 갖지 않을 수 도 있다. 예를 들면 전면에 나와있지 않은(not a foreground) 팝업창 내의 활성화된 요소는 포커스를 갖고 있지 않다.</p> +</div> + +<h2 id="Syntax" name="Syntax">구문</h2> + +<pre>focused = document.hasFocus();</pre> + +<h3 id="반환_값">반환 값</h3> + +<p>문서 내의 활성화된 요소가 포커스를 갖고 있지 않으면 <code>false</code>를 반환, 포커스를 갖고 있다면 <code>true</code>를 반환</p> + +<h2 id="Example" name="Example">예제</h2> + +<pre><code><!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="UTF-8" /> +<title>TEST</title> +<style> +#message { font-weight: bold; } +</style> + +<script> + +setInterval( CheckPageFocus, 200 ); + +function CheckPageFocus() { + var info = document.getElementById("message"); + + if ( document.hasFocus() ) { + info.innerHTML = "The document has the focus."; + } else { + info.innerHTML = "The document doesn't have the focus."; + } +} + +function OpenWindow() { + window.open ( + "http://developer.mozilla.org/", + "mozdev", + width=640, + height=300, + left=150, + top=260 + ); +} + +</script> +</head> + +<body> + <h1>JavaScript hasFocus example</h1> + <div id="message">Waiting for user action</div> + <div><button onclick="OpenWindow()">Open a new window</button></div> +</body> +</html></code></pre> + +<h2 id="Specification" name="Specification">명세</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', 'interaction.html#dom-document-hasfocus', 'Document.hasFocus()')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="브라우저_호환성">브라우저 호환성</h2> + +<p>{{Compat("api.Document.hasFocus")}}</p> + +<h2 id="관련_참고">관련 참고</h2> + +<ul> + <li><a href="https://developer.mozilla.org/ko/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API">페이지 가시성 API 사용하기</a></li> +</ul> |
