问题
I am having an issue with contentEditable iframes in Firefox. I created an iframe for pasting rich text and it worked excellently in Chrome. However, for some reason the iframe is not editable in Firefox and IE. When I load the iframe in FF, the cursor blinks in the iframe and then disappears, never to return. Here is the HTML as it loads in Chrome:
<iframe id="atto_pastespecial_iframe" frameborder="0" style="border: 1px solid gray">
#document
<html>
<head></head>
<body contenteditable="true"></body>
</html>
</iframe>
However, here is how it looks in FF:
<iframe id="atto_pastespecial_iframe" frameborder="0" style="border: 1px solid gray">
#document
<html>
<head></head>
<body></body>
</html>
</iframe>
I am adding the HTML via YUI Javascript: (Edit to show how the iframe is added)
_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();
Does anyone know why the iframe is editable in Chrome, but not FF or IE?
来源:https://stackoverflow.com/questions/29422219/contenteditable-iframe-is-not-editable-in-firefox