技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> JavaScript --> 用js给fckeditor赋值的办法

用js给fckeditor赋值的办法

浏览:1439次  出处信息

    虽然用fckeditor很久了,但是对它并不熟悉,今天就碰到一个问题,就是如何通过js来对已经加载的fckeditor赋值,研究了半天也没搞定,后来我在网上看到了三个函数,写的真是太好了,拿过来和大家一块分享一下。

    //获取编辑器中HTML内容

    function getEditorHTMLContents(EditorName)

    {

    var oEditor = FCKeditorAPI.GetInstance(EditorName);

    return(oEditor.GetXHTML(true));

    }

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

    function getEditorTextContents(EditorName)

    {

    var oEditor = FCKeditorAPI.GetInstance(EditorName);

    return(oEditor.EditorDocument.body.innerText);

    }

    //设置编辑器中内容

    function SetEditorContents(EditorName, ContentStr)

    {

    var oEditor = FCKeditorAPI.GetInstance(EditorName) ;

    oEditor.SetHTML(ContentStr) ;

    }

QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1