aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/document/head/index.html
blob: af0331459f37fa2adf0c4ae885144d60e5e3bf64 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
title: Document.head
slug: Web/API/Document/head
translation_of: Web/API/Document/head
---
<p>{{APIRef("DOM")}}</p>

<p>Retorna o elemento {{HTMLElement("head")}} do documento atual. Se existir mais de um elemento <code>&lt;head&gt;</code>, apenas o primeiro será devolvido.</p>

<h2 id="Syntax" name="Syntax">Sintaxe</h2>

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

<h2 id="Example" name="Example">Exemplo</h2>

<pre class="brush: js">// No HTML: &lt;head id="my-document-head"&gt;
var aHead = document.head;

alert(aHead.id); // "my-document-head";

alert( document.head === document.querySelector("head") ); // true
</pre>

<h2 id="Example" name="Example">Notas</h2>

<p><code>document.head</code> suporta apenas leitura. Qualquer tentativa de atribuir um valor a essa propriedade irá falhar silenciosamente ou irá, usando o modo <a href="/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode">ECMAScript Strict</a> de um browser Gecko, disparar um <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError"><code>TypeError</code></a>.</p>

<h2 id="Especificações">Especificações</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Especificação</th>
   <th scope="col">Status</th>
   <th scope="col">Comentário</th>
  </tr>
  <tr>
   <td>{{SpecName("HTML5 W3C", "dom.html#dom-tree-accessors", "document.head")}}</td>
   <td>{{Spec2("HTML5 W3C")}}</td>
   <td>Definição inicial</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilidade_entre_Browsers">Compatibilidade entre Browsers</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Recurso</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>4.0</td>
   <td>{{CompatGeckoDesktop("2")}}</td>
   <td>9.0</td>
   <td>11.0</td>
   <td>5.0</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Recurso</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("2")}}</td>
   <td>9.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="sect1"> </h2>

<h2 id="Veja_Também">Veja Também</h2>

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