在fckeditor光标处插入指定字符

有时候在工作的时候需要将某些文字单独的插入到fckeditor编辑器中,但这时如果修改了fckeditor的源文件的话,再想插入其它的东西就还要再修改一次,很不方便 。于是搜了很久,但没有结果,于是柠檬园主给出了解决方案,在此谢谢柠檬园主。

看代码:
     function InsertHTML(e,inStr)
    {
     var oEditor = FCKeditorAPI.GetInstance(e) ;
     if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
     {
      // Insert the desired HTML.
      oEditor.InsertHtml( inStr ) ;
     }
     else
      alert( 'You must be on WYSIWYG mode!' ) ;
    }

    function ExecuteCommand( commandName,e )
    {
     var oEditor = FCKeditorAPI.GetInstance(e) ;
     oEditor.Commands.GetCommand( commandName ).Execute() ;
    }

调用代码:
  <a href="javascript:InsertHTML('obj','>>>>>>>>>>Pagination<<<<<<<<<<');">FCK有API可以用,可以直接在当前FCK编辑域的光标处执行动作的。</a>
‘下面的那个命令没有用到,应该是某些JS命令,在此没有用到。

对编辑器FCKeditor进行赋值:

var sString = '';

var oEditor = FCKeditorAPI.GetInstance('editor' );

oEditor.SetHTML(sString);
300*300
  • 没有相关文章
  • 没有评论
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00409 秒