-
Notifications
You must be signed in to change notification settings - Fork 8k
/
index.md
56 lines (40 loc) · 1.46 KB
/
index.md
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
---
title: "DOMImplementation: createDocument() メソッド"
slug: Web/API/DOMImplementation/createDocument
l10n:
sourceCommit: 41a8b9c9832359d445d136b6d7a8a28737badc6b
---
{{ApiRef("DOM")}}
**`DOMImplementation.createDocument()`** メソッドは、 {{domxref("XMLDocument")}} を作成して返します。
## 構文
```js-nolint
createDocument(namespaceURI, qualifiedNameStr)
createDocument(namespaceURI, qualifiedNameStr, documentType)
```
### 引数
- `namespaceURI`
- : 作成する文書の名前空間 URI を格納した文字列です。文書が名前空間に属さない場合は `null` です。
- `qualifiedNameStr`
- : 作成する文書の修飾名(オプションで接頭辞とコロンにローカルルート要素名を加えたもの)を格納した文字列です。
- `documentType` {{optional_inline}}
- : 作成する文書の {{domxref("DocumentType")}} です。既定値は `null` です。
### 返値
なし ({{jsxref("undefined")}})。
## 例
```js
const doc = document.implementation.createDocument(
"http://www.w3.org/1999/xhtml",
"html",
null,
);
const body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
body.setAttribute("id", "abc");
doc.documentElement.appendChild(body);
alert(doc.getElementById("abc")); // [object HTMLBodyElement]
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- 所属先の {{domxref("DOMImplementation")}} インターフェイス