aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/document/index.html
blob: df3d75e7ebf9cd7389f5723045f9ab491a23a29f (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
---
title: Document
slug: Web/API/Document
tags:
  - DOM
translation_of: Web/API/Document
---
<div>{{ ApiRef("DOM") }}</div>

<div></div>

<p>Каждая веб-страница, которая загружается в браузер, имеет свой собственный объект <strong>document</strong>. Интерфейс документа служит точкой входа для получения содержимого веб-страницы (всего <a href="/en-US/docs/Using_the_W3C_DOM_Level_1_Core" title="Using_the_W3C_DOM_Level_1_Core">DOM</a> - дерева, включая такие элементы как {{HTMLElement("body")}} и {{HTMLElement("table")}}), <span id="result_box" lang="ru"><span>а также обеспечивает функциональность</span><span>, которая является</span> <span>глобальной для</span> <span>документа</span><span>например, для получения</span> <span>URL-адреса </span><span>страницы</span> <span>и</span>ли <span>создания новых элементов</span> <span>в документе</span></span>).</p>

<p>Объект <strong>document</strong> может быть получен из разных API:</p>

<ul>
 <li>Чаще всего используется прямой доступ к объекту <strong>document</strong> из сценариев <a href="/en-US/docs/HTML/Element/Script" title="HTML/Element/Script">scripts</a> которые подгружаются документом. (Этот же объект доступен как {{domxref("window.document")}}.)</li>
 <li>Через свойство <code><a href="/en-US/docs/Web/API/HTMLIFrameElement#Properties" title="DOM/HTMLIFrameElement#Properties">contentDocument</a></code> объекта iframe.</li>
 <li>Как ответ <a href="/en-US/docs/Web/API/XMLHttpRequest#responseXML" title="XMLHttpRequest#responseXML"><code>responseXML</code></a> объекта  <a href="/en-US/docs/Web/API/XMLHttpRequest" title="XMLHttpRequest"><code>XMLHttpRequest.</code></a></li>
 <li>Доступ к документу может быть получен из элемента или узла через свойство  {{domxref("Node.ownerDocument","ownerDocument")}}.</li>
</ul>

<p>В зависимости от вида документа (т.е. <a href="/en-US/docs/HTML" title="HTML">HTML</a> или <a href="/en-US/docs/XML" title="XML">XML</a>) у объекта <strong>document</strong> могут быть доступны разные API.</p>

<ul>
 <li>Все объекты документов реализуют интерфейс <a href="http://dom.spec.whatwg.org/#interface-document"><code>Document</code></a> (и следовательно {{domxref("Node")}} и {{domxref("EventTarget")}} интерфейсы). Таким образом основные свойства и методы, описанные на этой странице, доступны для всех видов документов.</li>
 <li>В современных браузерах некоторые документы (т.е. те, которые содержат контент <code>text/html</code>) также реагируют  {{domxref("HTMLDocument")}} интерфейс.</li>
 <li>В современных браузерах SVG документы реализуют {{domxref("SVGDocument")}} интерфейс.</li>
</ul>

<p>В будущем все эти интерфейсы будут сведены в один интерфейс - <code>Document</code>.</p>

<h2 id="Properties" name="Properties">Свойства</h2>

<div class="note">
<p><strong>Примечание:</strong> Интерфейс <code>Document</code> наследует также интерфейсы {{domxref("Node")}} и {{domxref("EventTarget")}}.</p>
</div>

<dl>
 <dt>{{domxref("Document.all")}} {{Deprecated_inline}} {{non-standard_inline}}</dt>
 <dd>Обеспечивает доступ ко всем элементам с идентификаторами (id). Это нестандартный интерфейс, вместо него рекомендуется использовать метод {{domxref("Document.getElementById()")}}.</dd>
 <dt>{{domxref("Document.async")}} {{Deprecated_inline}}</dt>
 <dd>Используется с {{domxref("document.load")}} чтобы обозначить асинхронный запрос.</dd>
 <dt>{{domxref("Document.characterSet")}} {{experimental_inline}}</dt>
 <dd>Возвращает кодировку документа.</dd>
 <dt>{{domxref("Document.compatMode")}} {{experimental_inline}}</dt>
 <dd>Указывает в каком режиме (Quirks или Strict) рендерился документ.</dd>
 <dt>{{domxref("Document.contentType")}} {{experimental_inline}}</dt>
 <dd>Возвращает Content-Type из MIME заголовка текущего документа.</dd>
 <dt>{{domxref("Document.doctype")}}</dt>
 <dd>Возвращает Document Type Definition (DTD) текущего документа .</dd>
 <dt>{{domxref("Document.documentElement")}}</dt>
 <dd>Возвращает Element, который является первым дочерним элементом документа. Для HTML документов это HTML-элемент.</dd>
 <dt>{{domxref("Document.documentURI")}}</dt>
 <dd>Возвращает URL документа.</dd>
 <dt>{{domxref("Document.domConfig")}} {{Deprecated_inline}}</dt>
 <dd>Должен вернуть  {{domxref("DOMConfiguration")}} объект.</dd>
 <dt>{{domxref("Document.implementation")}}</dt>
 <dd>Возвращает DOM implementation связанную с текущим документом.</dd>
 <dt>{{domxref("Document.inputEncoding")}} {{Deprecated_inline}}</dt>
 <dd>Возвращает кодировку, которая использовалась во время парсинга документа.</dd>
 <dt>{{domxref("Document.lastStyleSheetSet")}}</dt>
 <dd>Возвращает имя последнего включённого набора таблиц стилей. Имеет значение <code>null</code> , пока таблица стилей не будет изменена путём установки значения {{domxref("Document.selectedStyleSheetSet","selectedStyleSheetSet")}}.</dd>
 <dt>{{domxref("Document.mozSyntheticDocument")}} {{non-standard_inline}} {{gecko_minversion_inline("8.0")}}</dt>
 <dd><code>true</code> если этот документ является синтетическим, например, отдельные изображения, видео, аудио файлы, или тому подобные.</dd>
 <dt>{{domxref("Document.mozFullScreen")}} {{non-standard_inline}} {{gecko_minversion_inline("9.0")}}</dt>
 <dd><code>true</code> когда документ находится в  {{domxref("Using_full-screen_mode","full-screen mode")}}.</dd>
 <dt>{{domxref("Document.mozFullScreenElement")}} {{non-standard_inline}} {{gecko_minversion_inline("9.0")}}</dt>
 <dd>Элемент, который в данный момент находится в полноэкранном режиме для этого документа.</dd>
 <dt>{{domxref("Document.mozFullScreenEnabled")}} {{non-standard_inline}} {{gecko_minversion_inline("9.0")}}</dt>
 <dd><code>true</code> if calling {{domxref("element.mozRequestFullscreen()")}} would succeed in the curent document.</dd>
 <dt>{{domxref("Document.pointerLockElement")}} {{experimental_inline}}</dt>
 <dd>Returns the element set as the target for mouse events while the pointer is locked. <code>null</code> if lock is pending, pointer is unlocked, or if the target is in another document.</dd>
 <dt>{{domxref("Document.preferredStyleSheetSet")}}</dt>
 <dd>Returns the preferred style sheet set as specified by the page author.</dd>
 <dt>{{domxref("Document.selectedStyleSheetSet")}}</dt>
 <dd>Returns which style sheet set is currently in use.</dd>
 <dt>{{domxref("Document.styleSheets")}}</dt>
 <dd>Returns a list of the style sheet objects on the current document.</dd>
 <dt>{{domxref("Document.styleSheetSets")}}</dt>
 <dd>Returns a list of the style sheet sets available on the document.</dd>
 <dt>{{domxref("Document.xmlEncoding")}} {{Deprecated_inline}}</dt>
 <dd>Returns the encoding as determined by the XML declaration.</dd>
 <dt>{{domxref("Document.xmlStandalone")}} {{obsolete_inline("10.0")}}</dt>
 <dd>Returns <code>true</code> if the XML declaration specifies the document to be standalone (<em>e.g.,</em> An external part of the DTD affects the document's content), else <code>false</code>.</dd>
 <dt>{{domxref("Document.xmlVersion")}} {{obsolete_inline("10.0")}}</dt>
 <dd>Returns the version number as specified in the XML declaration or <code>"1.0"</code> if the declaration is absent.</dd>
</dl>

<p>The <code>Document</code> interface is extended with the {{domxref("ParentNode")}} interface:</p>

<p>{{page("/en-US/docs/Web/API/ParentNode","Properties")}}</p>

<h3 id="Extension_for_HTML_documents">Extension for HTML documents</h3>

<p>The <code>Document</code> interface for HTML documents inherit from the {{domxref("HTMLDocument")}} interface or, since HTML5,  is extended for such documents:</p>

<dl>
 <dt>{{domxref("Document.activeElement")}}</dt>
 <dd>Returns the currently focused element.</dd>
 <dt>{{domxref("Document.alinkColor")}} {{Deprecated_inline}}</dt>
 <dd>Returns or sets the color of active links in the document body.</dd>
 <dt>{{domxref("Document.anchors")}}</dt>
 <dd>Returns a list of all of the anchors in the document.</dd>
 <dt>{{domxref("Document.applets")}} {{Deprecated_inline}}</dt>
 <dd>Returns an ordered list of the applets within a document.</dd>
 <dt>{{domxref("Document.bgColor")}} {{Deprecated_inline}}</dt>
 <dd>Gets/sets the background color of the current document.</dd>
 <dt>{{domxref("Document.body")}}</dt>
 <dd>Returns the {{HTMLElement("body")}} element of the current document.</dd>
 <dt>{{domxref("Document.cookie")}}</dt>
 <dd>Returns a semicolon-separated list of the cookies for that document or sets a single cookie.</dd>
 <dt>{{domxref("Document.defaultView")}}</dt>
 <dd>Returns a reference to the window object.</dd>
 <dt>{{domxref("Document.designMode")}}</dt>
 <dd>Gets/sets the ability to edit the whole document.</dd>
 <dt>{{domxref("Document.dir")}}</dt>
 <dd>Gets/sets directionality (rtl/ltr) of the document.</dd>
 <dt>{{domxref("Document.domain")}}</dt>
 <dd>Returns the domain of the current document.</dd>
 <dt>{{domxref("Document.embeds")}}</dt>
 <dd>Returns a list of the embedded {{HTMLElement('embed')}} elements within the current document.</dd>
 <dt>{{domxref("Document.fgColor")}} {{Deprecated_inline}}</dt>
 <dd>Gets/sets the foreground color, or text color, of the current document.</dd>
 <dt>{{domxref("Document.forms")}}</dt>
 <dd>Returns a list of the {{HTMLElement("form")}} elements within the current document.</dd>
 <dt>{{domxref("Document.head")}}</dt>
 <dd>Returns the {{HTMLElement("head")}} element of the current document.</dd>
 <dt>{{domxref("Document.height")}} {{non-standard_inline}} {{obsolete_inline}}</dt>
 <dd>Gets/sets the height of the current document.</dd>
 <dt>{{domxref("Document.images")}}</dt>
 <dd>Returns a list of the images in the current document.</dd>
 <dt>{{domxref("Document.lastModified")}}</dt>
 <dd>Returns the date on which the document was last modified.</dd>
 <dt>{{domxref("Document.linkColor")}} {{Deprecated_inline}}</dt>
 <dd>Gets/sets the color of hyperlinks in the document.</dd>
 <dt>{{domxref("Document.links")}}</dt>
 <dd>Returns a list of all the hyperlinks in the document.</dd>
 <dt>{{domxref("Document.location")}}</dt>
 <dd>Returns the URI of the current document.</dd>
 <dt>{{domxref("Document.plugins")}}</dt>
 <dd>Returns a list of the available plugins.</dd>
 <dt>{{domxref("Document.readyState")}} {{gecko_minversion_inline("1.9.2")}}</dt>
 <dd>Returns loading status of the document.</dd>
 <dt>{{domxref("Document.referrer")}}</dt>
 <dd>Returns the URI of the page that linked to this page.</dd>
 <dt>{{domxref("Document.scripts")}}</dt>
 <dd>Returns all the {{HTMLElement("script")}} elements on the document.</dd>
 <dt>{{domxref("Document.title")}}</dt>
 <dd>Returns the title of the current document.</dd>
 <dt>{{domxref("Document.URL")}}</dt>
 <dd>Returns a string containing the URL of the current document.</dd>
 <dt>{{domxref("Document.vlinkColor")}} {{Deprecated_inline}}</dt>
 <dd>Gets/sets the color of visited hyperlinks.</dd>
 <dt>{{domxref("Document.width")}} {{non-standard_inline}} {{obsolete_inline}}</dt>
 <dd>Returns the width of the current document.</dd>
</dl>

<h3 id="Event_handlers" name="Event_handlers">Event handlers</h3>

<dl>
 <dt>{{domxref("Document.onpointerlockchange")}} {{experimental_inline}}</dt>
 <dd>Returns the event handling code for the {{event("pointerlockchange")}} event.</dd>
 <dt>{{domxref("Document.onpointerlockerror")}} {{experimental_inline}}</dt>
 <dd>Returns the event handling code for the {{event("pointerlockerror")}} event.</dd>
 <dt>{{domxref("Document.onreadystatechange")}} {{gecko_minversion_inline("1.9.2")}}</dt>
 <dd>Returns the event handling code for the <code>readystatechange</code> event.</dd>
</dl>

<h2 id="Methods" name="Methods">Methods</h2>

<div class="note">
<p><strong>Note:</strong> The <code>Document</code> interface also inherits from the {{domxref("Node")}} and {{domxref("EventTarget")}} interfaces.</p>
</div>

<dl>
 <dt>{{domxref("Document.adoptNode","Document.adoptNode(Node node)")}}</dt>
 <dd>Adopt node from an external document.</dd>
 <dt>{{domxref("Document.captureEvents","Document.captureEvents(String eventName)")}} {{Deprecated_inline}}</dt>
 <dd>See {{domxref("window.captureEvents")}}.</dd>
 <dt>{{domxref("Document.caretPositionFromPoint","Document.caretPositionFromPoint(Number x, Number y)")}}</dt>
 <dd>Gets a {{domxref("CaretPosition")}} based on two coordinates.</dd>
 <dt>{{domxref("Document.createAttribute","Document.createAttribute(String name)")}}</dt>
 <dd>Creates a new {{domxref("Attr")}} object and returns it.</dd>
 <dt>{{domxref("Document.createAttributeNS","Document.createAttributeNS(String namespace, String name)")}}</dt>
 <dd>Creates a new attribute node in a given namespace and returns it.</dd>
 <dt>{{domxref("Document.createCDATASection","Document.createCDATASection(String data)")}}</dt>
 <dd>Creates a new CDATA node and returns it.</dd>
 <dt>{{domxref("Document.createComment","Document.createComment(String comment)")}}</dt>
 <dd>Creates a new comment node and returns it.</dd>
 <dt>{{domxref("Document.createDocumentFragment()")}}</dt>
 <dd>Creates a new document fragment.</dd>
 <dt>{{domxref("Document.createElement","Document.createElement(String name)")}}</dt>
 <dd>Creates a new element with the given tag name.</dd>
 <dt>{{domxref("Document.createElementNS","Document.createElementNS(String namespace, String name)")}}</dt>
 <dd>Creates a new element with the given tag name and namespace URI.</dd>
 <dt>{{domxref("Document.createEntityReference","Document.createEntityReference(String name)")}} {{obsolete_inline}}</dt>
 <dd>Creates a new entity reference object and returns it.</dd>
 <dt>{{domxref("Document.createEvent","Document.createEvent(String interface)")}}</dt>
 <dd>Creates an event object.</dd>
 <dt>{{domxref("Document.createNodeIterator","Document.createNodeIterator(Node root[, Number whatToShow[, NodeFilter filter]])")}}</dt>
 <dd>Creates a {{domxref("NodeIterator")}} object.</dd>
 <dt>{{domxref("Document.createProcessingInstruction","Document.createProcessingInstruction(String target, String data)")}}</dt>
 <dd>Creates a new {{domxref("ProcessingInstruction")}} object.</dd>
 <dt>{{domxref("Document.createRange()")}}</dt>
 <dd>Creates a {{domxref("Range")}} object.</dd>
 <dt>{{domxref("Document.createTextNode","Document.createTextNode(String text)")}}</dt>
 <dd>Creates a text node.</dd>
 <dt>{{domxref("Document.createTreeWalker","Document.createTreeWalker(Node root[, Number whatToShow[, NodeFilter filter]])")}}</dt>
 <dd>Creates a {{domxref("TreeWalker")}} object.</dd>
 <dt>{{domxref("Document.elementFromPoint","Document.elementFromPoint(Number x, Number y)")}}</dt>
 <dd>Returns the element visible at the specified coordinates.</dd>
 <dt>{{domxref("Document.enableStyleSheetsForSet","Document.enableStyleSheetsForSet(String name)")}}</dt>
 <dd>Enables the style sheets for the specified style sheet set.</dd>
 <dt>{{domxref("Document.exitPointerLock()")}} {{experimental_inline}}</dt>
 <dd>Release the pointer lock.</dd>
 <dt>{{domxref("Document.getElementsByClassName","Document.getElementsByClassName(String className)")}}</dt>
 <dd>Returns a list of elements with the given class name.</dd>
 <dt>{{domxref("Document.getElementsByTagName","Document.getElementsByTagName(String tagName)")}}</dt>
 <dd>Returns a list of elements with the given tag name.</dd>
 <dt>{{domxref("Document.getElementsByTagNameNS","Document.getElementsByTagNameNS(String namespace, String tagName)")}}</dt>
 <dd>Returns a list of elements with the given tag name and namespace.</dd>
 <dt>{{domxref("Document.importNode","Document.importNode(Node node, Boolean deep)")}}</dt>
 <dd>Returns a clone of a node from an external document.</dd>
 <dt>{{domxref("document.mozSetImageElement")}} {{non-standard_inline}} {{gecko_minversion_inline("2.0")}}</dt>
 <dd>Allows you to change the element being used as the background image for a specified element ID.</dd>
 <dt>{{domxref("Document.normalizeDocument()")}} {{obsolete_inline}}</dt>
 <dd>Replaces entities, normalizes text nodes, etc.</dd>
 <dt>{{domxref("Document.releaseCapture()")}} {{non-standard_inline}} {{gecko_minversion_inline("2.0")}}</dt>
 <dd>Releases the current mouse capture if it's on an element in this document.</dd>
 <dt>{{domxref("Document.releaseEvents")}} {{non-standard_inline}} {{Deprecated_inline}}</dt>
 <dd>See {{domxref("window.releaseEvents")}}.</dd>
 <dt>{{domxref("document.routeEvent")}} {{non-standard_inline}} {{obsolete_inline(24)}}</dt>
 <dd>See {{domxref("window.routeEvent")}}.</dd>
</dl>

<p>The <code>Document</code> interface is extended with the {{domxref("ParentNode")}} interface:</p>

<dl>
 <dt>{{domxref("Document.getElementById","Document.getElementById(String id)")}}</dt>
 <dd>Returns an object reference to the identified element.</dd>
 <dt>{{domxref("Document.querySelector","Document.querySelector(String selector)")}} {{gecko_minversion_inline("1.9.1")}}</dt>
 <dd>Returns the first Element node within the document, in document order, that matches the specified selectors.</dd>
 <dt>{{domxref("Document.querySelectorAll","Document.querySelectorAll(String selector)")}} {{gecko_minversion_inline("1.9.1")}}</dt>
 <dd>Returns a list of all the Element nodes within the document that match the specified selectors.</dd>
</dl>

<p>The <code>Document</code> interface is extended with the {{domxref("XPathEvaluator")}} interface:</p>

<dl>
 <dt>{{domxref("Document.createExpression","Document.createExpression(String expression, XPathNSResolver resolver)")}}</dt>
 <dd>Compiles an <code><a href="/en-US/docs/XPathExpression" title="XPathExpression">XPathExpression</a></code> which can then be used for (repeated) evaluations.</dd>
 <dt>{{domxref("Document.createNSResolver","Document.createNSResolver(Node resolver)")}}</dt>
 <dd>Creates an {{domxref("XPathNSResolver")}} object.</dd>
 <dt>{{domxref("Document.evaluate","Document.evaluate(String expression, Node contextNode, XPathNSResolver resolver, Number type, Object result)")}}</dt>
 <dd>Evaluates an XPath expression.</dd>
</dl>

<h3 id="Extension_for_HTML_documents_2">Extension for HTML documents</h3>

<p>The <code>Document</code> interface for HTML documents inherit from the {{domxref("HTMLDocument")}} interface or, since HTML5,  is extended for such documents:</p>

<dl>
 <dt>{{domxref("Document.clear()")}} {{non-standard_inline}} {{Deprecated_inline}}</dt>
 <dd>In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.</dd>
 <dt>{{domxref("Document.close()")}}</dt>
 <dd>Closes a document stream for writing.</dd>
 <dt>{{domxref("Document.execCommand","Document.execCommand(String command[, Boolean showUI[, String value]])")}}</dt>
 <dd>On an editable document, executes a formating command.</dd>
 <dt>{{domxref("Document.getElementsByName","Document.getElementsByName(String name)")}}</dt>
 <dd>Returns a list of elements with the given name.</dd>
 <dt>{{domxref("Document.getSelection()")}}</dt>
 <dd>Returns a {{domxref("Selection")}} object related to text selected in the document.</dd>
 <dt>{{domxref("Document.hasFocus()")}}</dt>
 <dd>Returns <code>true</code> if the focus is currently located anywhere inside the specified document.</dd>
 <dt>{{domxref("Document.open()")}}</dt>
 <dd>Opens a document stream for writing.</dd>
 <dt>{{domxref("Document.queryCommandEnabled","Document.queryCommandEnabled(String command)")}}</dt>
 <dd>Returns true if the formating command can be executed on the current range.</dd>
 <dt>{{domxref("Document.queryCommandIndeterm","Document.queryCommandIndeterm(String command)")}}</dt>
 <dd>Returns true if the formating command is in an indeterminate state on the current range.</dd>
 <dt>{{domxref("Document.queryCommandState","Document.queryCommandState(String command)")}}</dt>
 <dd>Returns true if the formating command has been executed on the current range.</dd>
 <dt>{{domxref("Document.queryCommandSupported","Document.queryCommandSupported(String command)")}}</dt>
 <dd>Returns true if the formating command is supported on the current range.</dd>
 <dt>{{domxref("Document.queryCommandValue","Document.queryCommandValue(String command)")}}</dt>
 <dd>Returns the current value of the current range for a formatting command.</dd>
 <dt>{{domxref("Document.registerElement","Document.registerElement(String tagname[, Object options])")}}</dt>
 <dd>Registers a new custom element in the browser and returns a constructor for the new element.</dd>
 <dt>{{domxref("Document.write","Document.write(String text)")}}</dt>
 <dd>Writes text in a document.</dd>
 <dt>{{domxref("Document.writeln","Document.writeln(String text)")}}</dt>
 <dd>Writes a line of text in a document.</dd>
</dl>

<h2 id="Specifications">Specifications</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('DOM1','#i-Document','Document')}}</td>
   <td>{{Spec2('DOM1')}}</td>
   <td>Initial definition for the interface</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Core','#i-Document','Document')}}</td>
   <td>{{Spec2('DOM2 Core')}}</td>
   <td>Supersede DOM 1</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Core','#i-Document','Document')}}</td>
   <td>{{Spec2('DOM3 Core')}}</td>
   <td>Supersede DOM 2</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM WHATWG','#interface-document','Document')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td>Intend to supersede DOM 3</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG','dom.html#the-document-object','Document')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Turn the {{domxref("HTMLDocument")}} interface into a <code>Document</code> extension.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 XPath','xpath.html#XPathEvaluator','XPathEvaluator')}}</td>
   <td>{{Spec2('DOM3 XPath')}}</td>
   <td>Define the {{domxref("XPathEvaluator")}} interface which extend <code>Document</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML Editing','#dom-document-getselection','Document')}}</td>
   <td>{{Spec2('HTML Editing')}}</td>
   <td>Extend the <code>Document</code> interface</td>
  </tr>
  <tr>
   <td>{{SpecName('CSSOM View','#extensions-to-the-document-interface','Document')}}</td>
   <td>{{Spec2('CSSOM View')}}</td>
   <td>Extend the <code>Document</code> interface</td>
  </tr>
  <tr>
   <td>{{SpecName('CSSOM','#extensions-to-the-document-interface','Document')}}</td>
   <td>{{Spec2('CSSOM')}}</td>
   <td>Extend the <code>Document</code> interface</td>
  </tr>
  <tr>
   <td>{{SpecName('Pointer Lock','#extensions-to-the-document-interface','Document')}}</td>
   <td>{{Spec2('Pointer Lock')}}</td>
   <td>Extend the <code>Document</code> interface</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<h3 id="Firefox_notes">Firefox notes</h3>

<p>Mozilla defines a set of non-standard properties made only for XUL content:</p>

<dl>
 <dt>{{domxref("document.currentScript")}} {{gecko_minversion_inline("2.0")}}</dt>
 <dd>Returns the {{HTMLElement("script")}} element that is currently executing.</dd>
 <dt>{{domxref("document.documentURIObject")}} {{gecko_minversion_inline("1.9")}}</dt>
 <dd>(<strong>Mozilla add-ons only!</strong>) Returns the {{Interface("nsIURI")}} object representing the URI of the document. This property only has special meaning in privileged JavaScript code (with UniversalXPConnect privileges).</dd>
 <dt>{{domxref("document.popupNode")}}</dt>
 <dd>Returns the node upon which a popup was invoked.</dd>
 <dt>{{domxref("document.tooltipNode")}}</dt>
 <dd>Returns the node which is the target of the current tooltip.</dd>
</dl>

<p>Mozilla also define some non-standard methods:</p>

<dl>
 <dt>{{domxref("Document.execCommandShowHelp")}} {{obsolete_inline("14.0")}}</dt>
 <dd>This method never did anything and always threw an exception, so it was removed in Gecko 14.0 {{geckoRelease("14.0")}}.</dd>
 <dt>{{domxref("Document.getBoxObjectFor")}} {{obsolete_inline}}</dt>
 <dd>Use the {{domxref("Element.getBoundingClientRect()")}} method instead.</dd>
 <dt>{{domxref("Document.loadOverlay")}}</dt>
 <dd>Loads a <a href="/en-US/docs/XUL_Overlays" title="XUL_Overlays">XUL overlay</a> dynamically. This only works in XUL documents.</dd>
 <dt>{{domxref("document.queryCommandText")}} {{obsolete_inline("14.0")}}</dt>
 <dd>This method never did anything but throw an exception, and was removed in Gecko 14.0 {{geckoRelease("14.0")}}.</dd>
</dl>

<h3 id="Internet_Explorer_notes">Internet Explorer notes</h3>

<p>Microsoft defines some non-standard properties:</p>

<dl>
 <dt>{{domxref("document.fileSize")}}* {{non-standard_inline}} {{obsolete_inline}}</dt>
 <dd>Returns size in bytes of the document. Starting with Internet Explorer 11, that property is no longer supported. See <a href="http://msdn.microsoft.com/en-us/library/ms533752%28v=VS.85%29.aspx">MSDN</a>.</dd>
 <dt><span style="font-weight: normal; line-height: 1.5;">Internet Explorer does not support all methods from the <code>Node</code> interface in the <code>Document</code> interface:</span></dt>
</dl>

<dl>
 <dt>{{domxref("document.contains")}}</dt>
 <dd>As a work-around, <code>document.body.contains()</code> can be used.</dd>
</dl>

<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>

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