此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

DocumentType:publicId 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

DocumentTypepublicId 只读属性返回文档的形式化标识符。

对于合成的 DocumentType,此属性将反映 DOMImplementation.createDocumentType() 参数中给出的值。

字符串。

示例

js
const docType = document.implementation.createDocumentType(
  "svg",
  "-//W3C//DTD SVG 1.1//EN",
  "http://www.w3.org/2000/svg",
);

console.log(docType.publicId); // 显示“-//W3C//DTD SVG 1.1//EN”

规范

Specification
DOM
# dom-documenttype-publicid

浏览器兼容性