FCKeditorAPI 手册

  1. function abc()    
  2.   {    
  3.    var checkContent =FCKeditorAPI.GetInstance("editor");//获取实例    
  4.    alert(checkContent.GetXHTML());//获取当前内容    
  5.    var newelement = document.createElement("a");    
  6.    newelement.href="#";    
  7.    newelement.innerHTML="df";    
  8.    checkContent.InsertElement(newelement);//前部添加元素(无返回值)    
  9.    var a=checkContent.InsertElementAndGetIt(newelement);//前部添加元素(返回元素)    
  10.    checkContent.InsertHtml("")//添加html    
  11.    checkContent.SetHTML("",true);//设置内容,后为bool,是否所见即所得    
  12.      
  13.   }    
  14.   function aaa()    
  15.   {    
  16.   var checkContent =FCKeditorAPI.GetInstance("editor");//获取实例    
  17.   checkContent.SwitchEditMode();//转变编辑模式    
  18.   checkContent.UpdateLinkedField();//更新关联文件    
  19.   }    
  20. function FCKeditor_OnComplete( checkContent )//当加载完    
  21.   {    
  22.    alert( checkContent.Name ) ;    
  23.   }    
  24.   
  25. //设置fckeditor为只读    
  26. function FCKeditor_OnComplete(editorInstance)    
  27.     {    
  28.         editorInstance.EditorDocument.body.disabled = true;    
  29.         editorInstance.EditorWindow.parent.document.getElementById          ('xExpanded').style.display = 'none';    
  30.         editorInstance.EditorWindow.parent.document.getElementById('xCollapsed').style.display = 'none';    
  31.         editorInstance.EditorWindow.blur();    
  32. }    
  33.   
  34. //向编辑器插入指定代码    
  35. function insertHTMLToEditor(codeStr){    
  36.   var oEditor = FCKeditorAPI.GetInstance("content");    
  37.   if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){    
  38.     oEditor.InsertHtml(codeStr);    
  39.   }else{    
  40.     return false;    
  41.   }    
  42. }    
  43. //统计编辑器中内容的字数    
  44. function getLength(){    
  45.   var oEditor = FCKeditorAPI.GetInstance("content");    
  46.   var oDOM = oEditor.EditorDocument;    
  47.   var iLength ;    
  48.   if(document.all){    
  49.     iLength = oDOM.body.innerText.length;    
  50.   }else{    
  51.     var r = oDOM.createRange();    
  52.     r.selectNodeContents(oDOM.body);    
  53.     iLength = r.toString().length;    
  54.   }    
  55.   alert(iLength);    
  56. }    
  57. //执行指定动作    
  58. function ExecuteCommand(commandName){    
  59.   var oEditor = FCKeditorAPI.GetInstance("content") ;    
  60.   oEditor.Commands.GetCommand(commandName).Execute() ;    
  61. }    
  62. //设置编辑器中内容    
  63. function SetContents(codeStr){    
  64.   var oEditor = FCKeditorAPI.GetInstance("content") ;    
  65.   oEditor.SetHTML(codeStr) ;    
  66. }    
  67.   
  68. //使用FCKEditor时使用js在光标处添加任意字符串    
  69. function InsertHTML(e,inStr)//e:FCKEditor的ID,inStr:要插入的信息    
  70. {    
  71.         var oEditor = FCKeditorAPI.GetInstance(e) ;    
  72.        if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )    
  73.           {    
  74.            oEditor.InsertHtml( inStr ) ;    
  75.         }    
  76.          else    
  77.             alert("You must be on WYSIWYG mode!" ) ;    
  78.     }    
  79.   
  80.     function ExecuteCommand( commandName,e )    
  81.      {    
  82.          var oEditor = FCKeditorAPI.GetInstance(e) ;    
  83.          oEditor.Commands.GetCommand(commandName ).Execute() ;    
  84.     }   

 

posted @ 2011-01-25 11:21  go on coding  阅读(2107)  评论(0编辑  收藏  举报
悠季瑜伽会馆