Document.designMode

document.designMode 控制整个文档是否可编辑。有效值为 "on""off" 。根据规范,该属性默认为 "off" 。Firefox 遵循此标准。早期版本的 Chrome 和 IE默认为 "inherit" 。从 Chrome 43 开始,默认值为 "off" ,并且不再支持  "inherit"。在 IE6 到 IE10 中,该值为大写。

语法

var mode = document.designMode;
document.designMode = "on" || "off";

示例

使一个 <iframe> 的文档可编辑:

iframeNode.contentDocument.designMode = "on";

规范

规范 状态 备注
HTML Living Standard
designMode
Living Standard Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
designModeChrome Full support 45
Notes
Full support 45
Notes
Notes Before Chrome 64, this property was accessed through the HTMLDocument alias.
Edge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support 45
Notes
Full support 45
Notes
Notes Before Chrome 64, this property was accessed through the HTMLDocument alias.
Chrome Android Full support 45
Notes
Full support 45
Notes
Notes Before Chrome 64, this property was accessed through the HTMLDocument alias.
Firefox Android ? Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

参见