aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/window/self/index.html
blob: 0e22bd94eda0f705f3d750a9eff05a5256a4e868 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: Window.self
slug: Web/API/Window/self
tags:
  - API
  - HTML DOM
  - Property
  - Read-only
  - Reference
  - Window
translation_of: Web/API/Window/self
---
<div>{{APIRef}}</div>

<p><code><strong>Window.self</strong></code> 읽기전용 속성은 자기 자신을 {{domxref("WindowProxy")}}로써 반환합니다. <code>window.self</code>로도 사용할 수 있고, <code>self</code>만 독립적으로 사용해 접근할 수 있습니다. 독립적으로 접근했을 때의 이점은 비 {{jsxref("Window")}} 환경인 {{domxref("Worker", "웹 워커", "", 0)}} 등도 비슷한 표기법을 사용한다는 것입니다. 이 때 <code>self</code><code>Window</code> 문맥에서는 <code>window.self</code>, 워커 문맥에서는 {{domxref("WorkerGlobalScope.self")}}와 같습니다.</p>

<h2 id="Notes" name="Notes">예제</h2>

<p>아래와 같이 쓴 <code>window.self</code>는 그냥 <code>window</code>로 바꿨을 때와 동일합니다.</p>

<pre class="brush:js">if (window.parent.frames[0] != window.self) {
    // this window is not the first frame in the list
}
</pre>

<p>이에 더해 브라우징 문맥의 현재 활성확된 문서에서는 <code>window</code>가 현재 전역 객체를 가리키므로 다음 네 줄의 코드는 모두 동일합니다.</p>

<pre class="brush:js">var w1 = window;
var w2 = self;
var w3 = window.window;
var w4 = window.self;
// w1, w2, w3, w4 모두 일치. 그러나 워커에서는 w2만 작동함
</pre>

<h2 id="Specification" name="Specification">명세</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', '#dom-self', 'Window.self')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>No difference from the latest snapshot {{SpecName("HTML5.1")}}</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5.1', 'browsers.html#dom-self', 'Window.self')}}</td>
   <td>{{Spec2('HTML5.1')}}</td>
   <td>No difference from the {{SpecName("HTML5 W3C")}}</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'browsers.html#dom-self', 'Window.self')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>First snapshot containing the definition of <code>Window.self</code>.</td>
  </tr>
 </tbody>
</table>

<h2 id="브라우저_호환성">브라우저 호환성</h2>



<p>{{Compat("api.Window.self")}}</p>

<h2 class="noinclude" id="같이_보기">같이 보기</h2>

<ul>
 <li>{{domxref("Worker")}}에서 같은 역할을 하는 {{domxref("WorkerGlobalScope.self")}}.</li>
</ul>