Document:designMode 属性

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.designMode 控制整个文档是否可编辑。有效值为 "on""off"。根据规范,该属性默认为 "off"。Firefox 遵循这一标准。早期版本的 Chrome 和 IE 默认为 "inherit"。从 Chrome 43 开始,默认为 "off" 并不再支持 "inherit"。在 IE6-10 中,该值为大写。

字符串,表示 designMode 是否(或应该)设置为开启或关闭。有效值为 onoff

示例

使 <iframe> 的文档可编辑:

js
iframeNode.contentDocument.designMode = "on";

规范

Specification
HTML
# dom-document-designmode-dev

浏览器兼容性

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
designMode

Legend

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

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

参见