aboutsummaryrefslogtreecommitdiff
path: root/files/it/web/api/document/body/index.html
blob: e13f8e14004361c4af6cad0bc0ca2f9e0a6a949d (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: Document.body
slug: Web/API/Document/body
tags:
  - API
  - DOM
  - HTML DOM
  - Proprietà
  - Referenza
translation_of: Web/API/Document/body
---
<div>{{APIRef("DOM")}}</div>

<p>La proprietà <strong><code>Document.body</code></strong> rappresenta il nodo {{HTMLElement("body")}}{{HTMLElement("frameset")}} del documento corrente, o <code>null</code> se non esiste alcun elemento di questo tipo.</p>

<h2 id="Sintassi">Sintassi</h2>

<pre class="syntaxbox">var <var>objRef</var> = document.body;
document.body = <var>objRef</var>;</pre>

<h2 id="Esempio">Esempio</h2>

<pre class="brush:js">// Dato questo HTML: &lt;body id="oldBodyElement"&gt;&lt;/body&gt;
alert(document.body.id); // "oldBodyElement"

var aNewBodyElement = document.createElement("body");

aNewBodyElement.id = "newBodyElement";
document.body = aNewBodyElement;
alert(document.body.id); // "newBodyElement"
</pre>

<h2 id="Appunti">Appunti</h2>

<p><code>document.body</code> è l'elemento che contiene il contenuto per il documento. Nei documenti con contenuto <code>&lt;body&gt;</code> restituisce l'elemento <code>&lt;body&gt;</code>, e nei documenti frameset, restituisce l'elemento <code>&lt;frameset&gt;</code> più esterno.</p>

<p>Anche se <code>body</code> è settabile, l'impostazione di un nuovo corpo su un documento rimuoverà efficacemente tutti i figli attuali dell'elemento <code>&lt;body&gt;</code>.</p>

<h2 id="Specifiche">Specifiche</h2>

<table class="spectable standard-table">
 <thead>
  <tr>
   <th scope="col">Specifica</th>
   <th scope="col">Stato</th>
   <th scope="col">Commento</th>
  </tr>
 </thead>
 <tbody>
  <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>
  <tr>
   <td>{{SpecName('DOM2 HTML','html.html#ID-56360201','Document.body')}}</td>
   <td>{{Spec2('DOM2 HTML')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('DOM1','level-one-html.html#attribute-body','Document.body')}}</td>
   <td>{{Spec2('DOM1')}}</td>
   <td>Definizione iniziale.</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilità_con_i_browser">Compatibilità con i browser</h2>



<div>{{Compat("api.Document.body")}}</div>

<h2 id="Vedi_anche">Vedi anche</h2>

<ul>
 <li>{{domxref("document.head")}}</li>
</ul>