DOMImplementation: createDocumentType() method
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.
Phương thức DOMImplementation.createDocumentType() trả về một đối tượng DocumentType có thể được sử dụng với DOMImplementation.createDocument khi tạo tài liệu hoặc được đưa vào tài liệu thông qua các phương thức như Node.insertBefore() hoặc Node.replaceChild().
Cú pháp
js
createDocumentType(name, publicId, systemId)
Tham số
name-
Một chuỗi chứa tên của doctype, như
html. Tương ứng với thuộc tínhDocumentType.name. publicId-
Một chuỗi chứa định danh
PUBLIC. Tương ứng với thuộc tínhDocumentType.publicId. systemId-
Một chuỗi chứa định danh
SYSTEM. Tương ứng với thuộc tínhDocumentType.systemId.
Giá trị trả về
Một DocumentType.
Ví dụ
js
const dt = document.implementation.createDocumentType(
"svg",
"-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);
const d = document.implementation.createDocument(
"http://www.w3.org/2000/svg",
"svg:svg",
dt,
);
console.log(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| DOM> # ref-for-dom-domimplementation-createdocumenttype①> |
Tương thích trình duyệt
Xem thêm
- Giao diện
DOMImplementationmà nó thuộc về.