ContentEditable iframe is not editable in firefox

一世执手 提交于 2019-12-24 14:17:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!