开发者

IE exec command rich text editing

开发者 https://www.devze.com 2022-12-08 02:56 出处:网络
I\'m tring to insert an image in a WYSIWYG editor, but I can\'t insert images in Internet Explorer(6/开发者_开发问答7), although it works fine within Firefox. It fails without throwing any errors.

I'm tring to insert an image in a WYSIWYG editor, but I can't insert images in Internet Explorer(6/开发者_开发问答7), although it works fine within Firefox. It fails without throwing any errors.

This is what I'm using:

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


Thanks for the answer, but as it turned out my problem appeared because IE couldn't insert the image if my iframe (the richeditor container) didn't have focus. So I used the following code just before trying to use execCommand and it worked.

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


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

Try:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号