如何在CKEditor中将文本附加到HTML源代码? [英] How can I append text to html source in CKEditor?
问题描述
在我的网络应用程序中使用CKEditor。通过点击一个链接我附加一些文本CKEditor。它工作正常。但是当我打开 source
选项卡时,我不能将此文本附加到现有源。你能帮我怎么办吗?先谢谢你。对我的英语很抱歉。
I use CKEditor in my web-application. By click on one link i appends some text to CKEditor. It works fine. But when I open source
tab, i can not append this text to the existing source. Can you help me how can I do it? Thank you in advance. Sorry for my english.
推荐答案
如果您要附加HTML文字,可以使用createFromHtml方法,
If you are trying to append HTML text, you could use the createFromHtml method like this for example:
var imgHtml = CKEDITOR.dom.element.createFromHtml("<img src=" + imageSrcUrl + " alt='' align='right'/>");
其中imageSrcUrl是图像位置,然后您可以将其插入ckeditor源代码如下: p>
where imageSrcUrl is the image location and then you can insert it into the ckeditor source like this:
CKEDITOR.instances.body.insertElement(imgHtml);
还有其他方法如insertHtml或insertText,可以检查CEditor API 以获取有关这些的更多详细信息。
There are other methods like insertHtml or insertText, you can check the CKEditor APIs for more details on these.
这篇关于如何在CKEditor中将文本附加到HTML源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!