Take a look at the sample code to insert an element in iFrame:
Code HTML4Strict:<html> <head> <title>Sample iFrame</title> </head> <body> <script language="javascript"> var o = document.createElement( "iframe" ); o.id = 'A'; document.body.appendChild( o ); p = document.createElement('p'); p.innerHTML = "Test"; alert( document.getElementById( 'A' ).contentWindow.document.body ); document.getElementById( 'A' ).contentWindow.document.body.appendChild( p ); </script> </body> </html>
This is working in Firefox. But this is not working in Internet Explorer (Getting null in the alert).
I got the same problem when working with FCK editor. Even the InsertElement() function is also returning error in Internet Explorer, working in Firefox.
In case of FCK editor I tried following cases:
Code JavaScript:p = document.createElement('p'); p.innerHTML = "Test"; FCKeditorAPI.GetInstance('FCKeditor1').InsertElement( p );
Code JavaScript:p = document.createElement('p'); p.innerHTML = "Test"; var objEditorDocument = document.getElementById('FCKeditor1___Frame').contentWindow.document.getElementsByTagName('iframe')[0].contentWindow.document.body; objEditorDocument.appendChild(p );
Code JavaScript:p = document.createElement('p'); p.innerHTML = "Test"; FCKeditorAPI.GetInstance('FCKeditor1').EditorDocument.body.appendChild( p );
None of the techniques worked for me.




Bookmarks