Javascript ContentEditable iframe在firefox中不可编辑
我对Firefox中的contentEditable iFrame有问题。我创建了一个iframe来粘贴富文本,它在Chrome中运行得非常好。但是,由于某些原因,iframe在Firefox和IE中不可编辑。当我在FF中加载iframe时,光标在iframe中闪烁,然后消失,再也不会返回。以下是在Chrome中加载的HTML:Javascript ContentEditable iframe在firefox中不可编辑,javascript,html,iframe,yui,contenteditable,Javascript,Html,Iframe,Yui,Contenteditable,我对Firefox中的contentEditable iFrame有问题。我创建了一个iframe来粘贴富文本,它在Chrome中运行得非常好。但是,由于某些原因,iframe在Firefox和IE中不可编辑。当我在FF中加载iframe时,光标在iframe中闪烁,然后消失,再也不会返回。以下是在Chrome中加载的HTML: <iframe id="atto_pastespecial_iframe" frameborder="0" style="border: 1px solid gr
<iframe id="atto_pastespecial_iframe" frameborder="0" style="border: 1px solid gray">
#document
<html>
<head></head>
<body contenteditable="true"></body>
</html>
</iframe>
但是,以下是FF中的外观:
<iframe id="atto_pastespecial_iframe" frameborder="0" style="border: 1px solid gray">
#document
<html>
<head></head>
<body></body>
</html>
</iframe>
我通过YUI-Javascript:Edit添加HTML,以显示iframe是如何添加的
_addIframe: function(container) { //Container points at div to insert iframe into
container.setHTML('<iframe id="atto_pastespecial_iframe" src="javascript: window.onload(document.getElementByTagName(\'body\').contentEditable=\'true\')" frameBorder="0" style="border: 1px solid gray"></iframe>');
var ifr = Y.one('#atto_pastespecial_iframe');
var doc = ifr.get('contentWindow.document');
// Set the iframe to be editable by the user
doc.one('body').setAttribute('contentEditable', 'true');
doc.one('body').focus();
有人知道为什么iframe可以在Chrome中编辑,但不能在FF或IE中编辑吗?我可以通过打开Inspector并编辑标记来获得在FF中可编辑的内容r单击,选择Edit as HTML并添加contenteditable=true。此外接程序将添加到标记中。如何自动实现这一点?我已经能够通过添加src=javascript:window.onloaddocument.getElementsByTagName'body'.contentEditable='true';,在FF中获得成功;,但这会导致IE在iframe中填充未找到的页面。有什么想法吗?你是如何创建iframe的?我正在用javascript加载它。我添加这些行是为了向您展示如何将iframe作为HTML插入。