Document:compatMode 属性

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.

Document.compatMode 只读属性表示文档是以怪异模式或标准模式渲染。

可以是一个枚举值:

  • 如果文档处于怪异模式,则为“BackCompat”。
  • 如果文档处于无怪异模式(也称为“标准模式”)或有限怪异模式(也称为“接近标准模式”)下,则为“CSS1Compat”。

备注: 所有这些模式现在都已经标准化,因此较旧的“标准模式”和“接近标准模式”名称已经不合逻辑,也不再在标准中使用。

示例

js
if (document.compatMode === "BackCompat") {
  // 怪异模式中
}

规范

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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
compatMode

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.