我已经构建了一个带有iframe和designMode的小型文本编辑器。(这是一个不是由me http://jsfiddle.net/Kxmaf/6/编码的示例。我在Stackoverflow上找到了它)。
如果我检索iframe (document.body.innerHTML)的内容,结果如下所示:<span style="font-weight: bold;">Test</span> Text <span style="font-style: italic;">Text</span> <span style="text-decoration: underline;">TT</span>
是否可以将designMode设置为使用标记而不是具有样式属性的跨度?
任何帮助都是非常感谢的:)
发布于 2012-07-06 16:31:58
在大多数浏览器(但IE除外)中,您可以使用"StyleWithCSS“命令在样式模式之间切换,从而允许您在使用<b>和<i>等元素设置样式或使用具有样式属性的<span>元素设置样式之间进行选择。您可以使用"StyleWithCSS“命令来完成此操作,在较旧的浏览器中回退到"UseCSS”。以下命令用于切换命令以使用非CSS版本:
try {
if (!document.execCommand("StyleWithCSS", false, useCss)) {
// The value required by UseCSS is the inverse of what you'd expect
document.execCommand("UseCSS", false, !useCss);
}
} catch (ex) {
// IE doesn't recognise these commands and throws.
}https://stackoverflow.com/questions/11232664
复制相似问题