aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/domimplementation/createdocument/index.html
blob: f8a17c9f3f8fa737ad2b1aa3bf0f1cd6adeb7b8e (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
---
title: DOMImplementation.createDocument()
slug: Web/API/DOMImplementation/createDocument
translation_of: Web/API/DOMImplementation/createDocument
---
<p>{{ApiRef("DOM")}}</p>

<p>O método <strong><code>DOMImplementation.createDocument()</code></strong> cria e retorna um {{domxref("XMLDocument")}}.</p>

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

<pre class="syntaxbox"><em>doc</em> = document.implementation.createDocument(<em>namespaceURI</em>, <em>qualifiedNameStr</em>, <em>documentType</em>);</pre>

<h3 id="Parâmetros">Parâmetros</h3>

<dl>
 <dt><em>namespaceURI</em></dt>
 <dd>É um {{domxref("DOMString")}} contendo a URI do namespace do documento que será criado, ou <code>null</code> se o documento não pertencer a nenhum.</dd>
</dl>

<dl>
 <dt><em>qualifiedNameStr </em></dt>
 <dd>Is a {{domxref("DOMString")}} containing the qualified name, that is an optional prefix and colon plus the local root element name, of the document to be created.</dd>
</dl>

<dl>
 <dt><em>documentType </em>{{optional_inline}}</dt>
 <dd>
 <p>Is the {{domxref("DocumentType")}} of the document to be created. It defaults to <code>null</code>.</p>
 </dd>
</dl>

<ul>
</ul>

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

<pre class="brush: js">var doc = document.implementation.createDocument ('http://www.w3.org/1999/xhtml', 'html', null);
var body = document.createElementNS('http://www.w3.org/1999/xhtml', 'body');
body.setAttribute('id', 'abc');
doc.documentElement.appendChild(body);
alert(doc.getElementById('abc')); // [object HTMLBodyElement]
</pre>

<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('DOM WHATWG', '#dom-domimplementation-createdocument', 'DOMImplementation.createDocument')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td>Modified the return type of <code>createDocument()</code> from {{domxref("Document")}} to {{domxref("XMLDocument")}}.<br>
    The third argument of <code>createDocument()</code>, <em>doctype</em>, is now optional and default to <code>null</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Core', 'core.html#Level-2-Core-DOM-createDocument', 'DOMImplementation.createDocument')}}</td>
   <td>{{Spec2('DOM3 Core')}}</td>
   <td>No change from {{SpecName("DOM2 Core")}}</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Core', 'core.html#Level-2-Core-DOM-createDocument', 'DOMImplementation.createDocument')}}</td>
   <td>{{Spec2('DOM2 Core')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>



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

<h2 id="See_also">See also</h2>

<ul>
 <li>The {{domxref("DOMImplementation")}} interface it belongs to.</li>
</ul>