TextArea使用了ckeditor编辑器后,怎么用JS在Textarea中自动追加值

TextArea使用了ckeditor编辑器后,怎么用JS在Textarea中自动追加值,第1张

需要利用CKEDITOR的JavaScript API接口 getData() 获取编辑器内容 setData() 设置编辑器的内容 insertHTML() 在当前光标位置插入HTML代码不过遗憾的是没有在末尾追加HTML代码的函数,但是可以使用getData()和setData()组合使用实现。假设编辑器替换的TextArea的id位myEditor,则使用方法如下: var htmlData=CKEDITORinstancesmyEditorgetData(); var appEndData="追加的内容"; var theData=htmlData+appEndData; CKEDITORinstancesmyEditorsetData(theData);

参考资料:

>

利用Javascript取和设FCKeditor值也是非常容易的,如下:

// 获取编辑器中HTML内容

function getEditorHTMLContents(EditorName) {

var oEditor = FCKeditorAPIGetInstance(EditorName);

return(oEditorGetXHTML(true));

}

// 获取编辑器中文字内容

function getEditorTextContents(EditorName) {

var oEditor = FCKeditorAPIGetInstance(EditorName);

return(oEditorEditorDocumentbodyinnerText);

}

// 设置编辑器中内容

function SetEditorContents(EditorName, ContentStr) {

var oEditor = FCKeditorAPIGetInstance(EditorName) ;

oEditorSetHTML(ContentStr) ;

}

以上就是关于TextArea使用了ckeditor编辑器后,怎么用JS在Textarea中自动追加值全部的内容,包括:TextArea使用了ckeditor编辑器后,怎么用JS在Textarea中自动追加值、ckeditor编辑器如何从后台给他赋值、js如何获得FCKeditor控件的值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9798987.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-02
下一篇2023-05-02

发表评论

登录后才能评论

评论列表(0条)

    保存