blob: adc40e872e706fc8c23a3c18406b649aab32aeef (
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
73
74
|
---
title: Document.body
slug: Web/API/Document/body
tags:
- API
- DOM
- Document
- Property
- Reference
translation_of: Web/API/Document/body
---
<div>{{APIRef("DOM")}}</div>
<p><code><strong>Document.</strong><strong>body</strong></code> 속성은 현재 문서의 {{htmlelement("body")}} 혹은 {{htmlelement("frameset")}} 노드를 나타냅니다. 일치하는 요소가 존재하지 않으면 <code>null</code>을 반환합니다.</p>
<h2 id="구문">구문</h2>
<pre>const <em>objRef</em> = document.body
document.body = <em>objRef</em>
</pre>
<h2 id="Example" name="Example">예제</h2>
<pre class="brush: js">// HTML: <body id="oldBodyElement"></body>
alert(document.body.id); // "oldBodyElement"
let aNewBodyElement = document.createElement("body");
aNewBodyElement.id = "newBodyElement";
document.body = aNewBodyElement;
alert(document.body.id); // "newBodyElement"</pre>
<h2 id="Notes" name="Notes">참고</h2>
<p><code>Document.body</code>는 문서의 콘텐츠를 수용하는 요소입니다. <code><body></code> 콘텐츠를 가지고 있는 문서는 <code><body></code> 요소를 반환하고, 프레임셋을 가지고 있는 문서는 가장 바깥쪽의 <code><frameset></code> 요소를 반환합니다.</p>
<p><code>body</code> 속성에 새로운 값을 설정할 수 있긴 하지만, 문서에 새로운 본문을 설정하는건 <code><body></code> 요소가 가지고 있던 모든 자식을 제거하는 것과 같습니다.</p>
<h2 id="Specification" name="Specification">명세</h2>
<table class="spectable 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.html#dom-document-body','Document.body')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML5.1','dom.html#dom-document-body','Document.body')}}</td>
<td>{{Spec2('HTML5.1')}}</td>
<td></td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C','dom.html#dom-document-body','Document.body')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="브라우저_호환성">브라우저 호환성 </h2>
<p>{{Compat("api.Document.body")}}</p>
<h2 id="같이_보기">같이 보기</h2>
<ul>
<li>{{domxref("Document.head")}}</li>
</ul>
|