Document: thuộc tính doctype

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.

Thuộc tính chỉ đọc doctype của giao diện Document là một đối tượng DocumentType biểu thị Document Type Declaration (DTD) được liên kết với tài liệu hiện tại.

Giá trị

Một đối tượng DocumentType.

Ví dụ

js
const doctypeObj = document.doctype;

console.log(`doctypeObj.name: ${doctypeObj.name}`);
console.log(`doctypeObj.internalSubset: ${doctypeObj.internalSubset}`);
console.log(`doctypeObj.publicId: ${doctypeObj.publicId}`);
console.log(`doctypeObj.systemId: ${doctypeObj.systemId}`);

Ghi chú

Thuộc tính trả về null nếu không có DTD nào được liên kết với tài liệu hiện tại.

DOM level 2 không hỗ trợ chỉnh sửa phần khai báo loại tài liệu.

Các đặc tả kỹ thuật

Specification
DOM
# ref-for-dom-document-doctype①

Tương thích trình duyệt