[英]IE exec command rich text editing
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. 我试图在WYSIWYG编辑器中插入图像,但是我无法在Internet Explorer(6/7)中插入图像,尽管它在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. 感谢您的回答,但事实证明我的问题出现了,因为如果我的iframe(richeditor容器)没有焦点,则IE无法插入图像。 So I used the following code just before trying to use execCommand and it worked.
因此,在尝试使用execCommand之前,我使用了以下代码,它可以正常工作。
document.getElementById('iframeId').contentWindow.focus();
In IE, execCommand exists on the document object, not the window object. 在IE中,execCommand存在于文档对象上,而不是窗口对象上。 (Well, it also exists on range objects, too, but anyway.)
(好吧,它也存在于范围对象上,但是无论如何。)
Try: 尝试:
document.execCommand("insertImage", false, "absolute/path/to/an/image");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.