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 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 9Safari Full support 1.2WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0

Legend

Full support  
Full support

参见