aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/document/head/index.html
blob: 8645de05b44b92779ce1f88badd8905e4acdeba1 (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
---
title: Document.head
slug: Web/API/Document/head
tags:
  - API
  - Document
  - Property
translation_of: Web/API/Document/head
---
<p>{{APIRef("DOM")}}</p>

<p>Возвращает элемент {{HTMLElement("head")}} текущего документа. Если имеется более одного элемента <code>&lt;head&gt;</code>, будет возвращен первый из них.</p>

<h2 id="Syntax" name="Syntax">Синтаксис</h2>

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



<h3 id="Значение">Значение</h3>

<p>{{domxref("HTMLHeadElement")}}.</p>



<h2 id="Пример">Пример</h2>

<pre class="notranslate"><code>&lt;!doctype html&gt;
&lt;head id="my-document-head"&gt;
  &lt;title&gt;Example: using document.head&lt;/title&gt;
&lt;/head&gt;

&lt;script&gt;
  var theHead = document.head;

  console.log(theHead.id); // "my-document-head";

  console.log( theHead === document.querySelector("head") ); // true
&lt;/script&gt;</code></pre>

<h2 id="Примечание">Примечание</h2>

<p><code>document.head</code> доступно только для чтения. Присвоить значение этому свойству нельзя. При попытке это сделать ошибка вызвана не будет, только если вы не используете <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode">Strict Mode</a>. В данном случае будет вызвано {{jsxref("TypeError")}} .</p>



<h2 id="Спецификации">Спецификации</h2>

<table class="spectable standard-table">
 <tbody>
  <tr>
   <th scope="col">Спецификация</th>
   <th scope="col">Статус</th>
   <th scope="col">Комментарий</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG','dom.html#dom-document-head','Document.head')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Начальное определение.</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5.1','dom.html#dom-document-head','Document.head')}}</td>
   <td>{{Spec2('HTML5.1')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C','dom.html#dom-document-head','Document.head')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="Браузерная_поддержка">Браузерная поддержка</h2>

<div class="hidden">
<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>and send us a pull request.</p>
</div>

<p>{{Compat("api.Document.head")}}</p>

<h2 id="Смотрите_также">Смотрите также</h2>

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