I create a new iframe then append it to the main window document and execute this javascript:
frame.contentDocument.execCommand('insertimage',0,'obama.jpg');
Where frame is the iframe element. Unfortunatey I get this error:
Error: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLDocument.execCommand]
How can I enable execCommand() function in an iframe? Is there something missing?
The document needs to be editable. This can be done by either of the followin methods:
execCommandought to be used for editable elements only. Your error indicates that this is not the case. If you want to insert a new image in the document, just use: