DOMImplementation: createDocument() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
DOMImplementation.createDocument()
メソッドは、 XMLDocument
を作成して返します。
構文
js
createDocument(namespaceURI, qualifiedNameStr)
createDocument(namespaceURI, qualifiedNameStr, documentType)
引数
namespaceURI
-
作成する文書の名前空間 URI を格納した文字列です。文書が名前空間に属さない場合は
null
です。 qualifiedNameStr
-
作成する文書の修飾名(オプションで接頭辞とコロンにローカルルート要素名を加えたもの)を格納した文字列です。
documentType
省略可-
作成する文書の
DocumentType
です。既定値はnull
です。
返値
なし (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]
仕様書
Specification |
---|
DOM # ref-for-dom-domimplementation-createdocument② |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
createDocument |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
関連情報
- 所属先の
DOMImplementation
インターフェイス