IE exec command line advanced text editing

I am trying to insert an image in a WYSIWYG editor, but I cannot insert images in Internet Explorer (6/7), although it works fine in Firefox. It does not reset any errors.

This is what I am using:

execCommand('insertImage', false, 'absolute/path/to/an/image');

      

+2


source to share


2 answers


Thanks for the answer, but as it turned out, my problem came from IE not being able to insert the image if there was no focus in my iframe (richeditor container). So I used the following code before trying to use execCommand and it worked.



document.getElementById('iframeId').contentWindow.focus();

      

+3


source


In IE, the execCommand exists on the document object, not the window object. (Well, it also exists for range objects, but anyway.)

Try:



document.execCommand("insertImage", false, "absolute/path/to/an/image");

      

+1


source







All Articles